Skip to content

Commit

Permalink
Adding in a new error message with handlers, for when Geolocation fai…
Browse files Browse the repository at this point in the history
…ls (fixes #42)
  • Loading branch information
SherriAlexander committed Sep 30, 2014
1 parent 014a659 commit a09d1bc
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 38 deletions.
2 changes: 2 additions & 0 deletions _site/bylocation.html
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ <h2 class="h3 no-link">Near you</h2>

<p id="footer-slider-msg-noeventsnearby" class="footer-slider-msg">There are no exhibitions within <span id="location-radius">X</span> miles of your current location.</p>

<p id="footer-slider-msg-nogeolocation" class="footer-slider-msg">Artbot couldn't detect your location.</p>

</div>

<div id="near-you-slider" class="footer-slider">
Expand Down
2 changes: 2 additions & 0 deletions _site/event.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ <h2 class="h3 related">Related: <span id="target-relatedinterest"></span></h2>

<p id="footer-slider-msg-noeventsnearby" class="footer-slider-msg">There are no exhibitions within <span id="location-radius">X</span> miles of your current location.</p>

<p id="footer-slider-msg-nogeolocation" class="footer-slider-msg">Artbot couldn't detect your location.</p>

</div>

<div id="related-interest-slider" class="footer-slider">
Expand Down
2 changes: 2 additions & 0 deletions _site/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ <h2 class="h3 no-link if-not-loggedin">My favorites</h2>

<p id="footer-slider-msg-noeventsnearby" class="footer-slider-msg">There are no exhibitions within <span id="location-radius">X</span> miles of your current location.</p>

<p id="footer-slider-msg-nogeolocation" class="footer-slider-msg">Artbot couldn't detect your location.</p>

</div>

<div id="favorites-slider" class="footer-slider">
Expand Down
2 changes: 2 additions & 0 deletions _site/styleguide.html
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ <h2 class="h3 no-link if-not-loggedin">My favorites</h2>

<p id="footer-slider-msg-noeventsnearby" class="footer-slider-msg">There are no exhibitions within <span id="location-radius">X</span> miles of your current location.</p>

<p id="footer-slider-msg-nogeolocation" class="footer-slider-msg">Artbot couldn't detect your location.</p>

</div>

<div id="" class="footer-slider">
Expand Down
27 changes: 22 additions & 5 deletions _site/ui/js/scripts-concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -24057,7 +24057,7 @@ Artbot.signupModal = {
console.log(data);
$.cookie('token', data.user.authentication_token);
$.cookie('currentuser', $("#email").val());
$.cookie('signedup', true);
$.cookie('signedup', true, { expires: 3650 });
$.mobile.pageContainer.pagecontainer ("change", "interests.html", {reloadPage: true});
},
error: function (jqXHR, error, errorThrown) {
Expand All @@ -24069,8 +24069,14 @@ Artbot.signupModal = {
});
},
open: function() {
// Record which page you're currently on
Artbot.signupModal.vars.returnToPage = $(".ui-page-active").attr("data-url");
// Record which page to return to after signup
if ($(".ui-page-active").attr("data-url") != "/sign-in.html") {
Artbot.signupModal.vars.returnToPage = $(".ui-page-active").attr("data-url");
} else {
Artbot.signupModal.vars.returnToPage = "/index.html";
}

console.log("Return to page: " + Artbot.signupModal.vars.returnToPage);

// Load up the form into the modal window
$.mobile.loading('show');
Expand Down Expand Up @@ -24894,6 +24900,9 @@ Artbot.historyList = {
if (($("#history-form").find("input[type=checkbox]").length > 0) && ($.cookie('token') !== undefined)) {
console.log("Syncing attendance checkboxes with user's attended records");

// Reset the form, in case of caching (we want a fresh copy)
document.getElementById("history-form").reset();

// Fetch the list of user's history to check against.
$.ajax({
type: "GET",
Expand Down Expand Up @@ -24937,9 +24946,16 @@ Artbot.historyList = {
$thisCheckbox.trigger("click");
}
}

});

// Debugging: Quick check to list out which are checked after sync
var allCheckboxes = $("#history-form").find(".customize-checkbox");
$.each(allCheckboxes, function(i, value) {
var tempIsCheckboxChecked = $(this).prop("checked");
var tempUserFavoriteID = $(this).attr("data-user-favorite-id");
console.log("User favorite: " + tempUserFavoriteID + ", Value of property 'checked' after syncing: " + tempIsCheckboxChecked);
});

Artbot.historyList.bindAttendanceCheckboxes();

}
Expand Down Expand Up @@ -25401,6 +25417,7 @@ Artbot.login = {
$.cookie('token', data.authentication_token);
$.cookie('currentuser', $("#email").val());
$.cookie('currentuser', $("#signin-email").val());
$.cookie('signedup', true, { expires: 3650 });
if (!Artbot.el.html.hasClass("is-logged-in")) {
Artbot.el.html.addClass("is-logged-in");
}
Expand Down Expand Up @@ -25775,7 +25792,7 @@ Artbot.startup = {
}
} else {
// If they're a new visitor, pop the Sign Up window
if (Artbot.var.hasVisitedBefore !== true) {
if (($.cookie('token') === undefined) && (Artbot.var.hasVisitedBefore !== true) && ($(".ui-page-active").attr("data-url") != "/sign-in.html")) {

console.log("Popping the new visitor sign up window");
setTimeout(function(){
Expand Down
6 changes: 3 additions & 3 deletions _site/ui/js/scripts-concat.min.js

Large diffs are not rendered by default.

27 changes: 22 additions & 5 deletions _site/ui/js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ Artbot.signupModal = {
console.log(data);
$.cookie('token', data.user.authentication_token);
$.cookie('currentuser', $("#email").val());
$.cookie('signedup', true);
$.cookie('signedup', true, { expires: 3650 });
$.mobile.pageContainer.pagecontainer ("change", "interests.html", {reloadPage: true});
},
error: function (jqXHR, error, errorThrown) {
Expand All @@ -1081,8 +1081,14 @@ Artbot.signupModal = {
});
},
open: function() {
// Record which page you're currently on
Artbot.signupModal.vars.returnToPage = $(".ui-page-active").attr("data-url");
// Record which page to return to after signup
if ($(".ui-page-active").attr("data-url") != "/sign-in.html") {
Artbot.signupModal.vars.returnToPage = $(".ui-page-active").attr("data-url");
} else {
Artbot.signupModal.vars.returnToPage = "/index.html";
}

console.log("Return to page: " + Artbot.signupModal.vars.returnToPage);

// Load up the form into the modal window
$.mobile.loading('show');
Expand Down Expand Up @@ -1906,6 +1912,9 @@ Artbot.historyList = {
if (($("#history-form").find("input[type=checkbox]").length > 0) && ($.cookie('token') !== undefined)) {
console.log("Syncing attendance checkboxes with user's attended records");

// Reset the form, in case of caching (we want a fresh copy)
document.getElementById("history-form").reset();

// Fetch the list of user's history to check against.
$.ajax({
type: "GET",
Expand Down Expand Up @@ -1949,9 +1958,16 @@ Artbot.historyList = {
$thisCheckbox.trigger("click");
}
}

});

// Debugging: Quick check to list out which are checked after sync
var allCheckboxes = $("#history-form").find(".customize-checkbox");
$.each(allCheckboxes, function(i, value) {
var tempIsCheckboxChecked = $(this).prop("checked");
var tempUserFavoriteID = $(this).attr("data-user-favorite-id");
console.log("User favorite: " + tempUserFavoriteID + ", Value of property 'checked' after syncing: " + tempIsCheckboxChecked);
});

Artbot.historyList.bindAttendanceCheckboxes();

}
Expand Down Expand Up @@ -2413,6 +2429,7 @@ Artbot.login = {
$.cookie('token', data.authentication_token);
$.cookie('currentuser', $("#email").val());
$.cookie('currentuser', $("#signin-email").val());
$.cookie('signedup', true, { expires: 3650 });
if (!Artbot.el.html.hasClass("is-logged-in")) {
Artbot.el.html.addClass("is-logged-in");
}
Expand Down Expand Up @@ -2787,7 +2804,7 @@ Artbot.startup = {
}
} else {
// If they're a new visitor, pop the Sign Up window
if (Artbot.var.hasVisitedBefore !== true) {
if (($.cookie('token') === undefined) && (Artbot.var.hasVisitedBefore !== true) && ($(".ui-page-active").attr("data-url") != "/sign-in.html")) {

console.log("Popping the new visitor sign up window");
setTimeout(function(){
Expand Down
2 changes: 2 additions & 0 deletions _site/venue.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ <h2 class="h3 related">Events &amp; Exhibitions</h2>

<p id="footer-slider-msg-noeventsnearby" class="footer-slider-msg">There are no exhibitions within <span id="location-radius">X</span> miles of your current location.</p>

<p id="footer-slider-msg-nogeolocation" class="footer-slider-msg">Artbot couldn't detect your location.</p>

</div>

<div id="venue-events-slider" class="footer-slider">
Expand Down
2 changes: 2 additions & 0 deletions _source/_includes/_slider-footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

<p id="footer-slider-msg-noeventsnearby" class="footer-slider-msg">There are no exhibitions within <span id="location-radius">X</span> miles of your current location.</p>

<p id="footer-slider-msg-nogeolocation" class="footer-slider-msg">Artbot couldn't detect your location.</p>

</div>

<div id="{{ page.footerslidertype }}" class="footer-slider">
Expand Down
30 changes: 19 additions & 11 deletions _source/ui/js/scripts-concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -23445,7 +23445,7 @@ Artbot.footerSlider = {
Artbot.footerSlider.initSlider();
} else {
// No favorites returned, show the "no favorites yet" message
$("#footer-slider-msg-nofavorites").fadeIn(400);
Artbot.footerSlider.showErrorMsg("nofavorites");
}
},
error: function (jqXHR, error, errorThrown) {
Expand All @@ -23458,7 +23458,7 @@ Artbot.footerSlider = {
} else {

// User is not logged in, show the appropriate message
$("#footer-slider-msg-favoritesignup").fadeIn(400);
Artbot.footerSlider.showErrorMsg("favoritesignup");

}
} else if ($("#venue-events-slider").length > 0) {
Expand Down Expand Up @@ -23493,7 +23493,7 @@ Artbot.footerSlider = {
Artbot.footerSlider.initSlider();
} else {
// No events returned, show the "no events" message
$("#footer-slider-msg-noevents").fadeIn(400);
Artbot.footerSlider.showErrorMsg("noevents");
}
},
error: function (jqXHR, error, errorThrown) {
Expand Down Expand Up @@ -23535,8 +23535,7 @@ Artbot.footerSlider = {
Artbot.footerSlider.cycleRelatedInterests(Artbot.var.relatedInterests);

} else {
// TODO: Show error for no results
$("#footer-slider-msg-noevents").fadeIn(400);
Artbot.footerSlider.showErrorMsg("noevents");
}

} else if ($("#near-you-slider").length > 0) {
Expand All @@ -23545,7 +23544,7 @@ Artbot.footerSlider = {
console.log("Initializing Near You slider");

// First, we have to try to get the user's current position.
Artbot.geolocation.getLocation(Artbot.footerSlider.processNearbyEvents, Artbot.footerSlider.hideFooter);
Artbot.geolocation.getLocation(Artbot.footerSlider.processNearbyEvents, Artbot.footerSlider.showGeolocationError);

}
},
Expand Down Expand Up @@ -23585,7 +23584,7 @@ Artbot.footerSlider = {
} else {
// No events returned, show the "no events in radius" message
$("#location-radius").html(Artbot.footerSlider.vars.locationRadius);
$("#footer-slider-msg-noeventsnearby").fadeIn(400);
Artbot.footerSlider.showErrorMsg("noeventsnearby");
}
},
error: function (jqXHR, error, errorThrown) {
Expand All @@ -23598,8 +23597,8 @@ Artbot.footerSlider = {
}
});
} else {
// Couldn't get a position; hide footer
Artbot.footerSlider.hideFooter();
// Couldn't get a position; show error message
Artbot.footerSlider.showErrorMsg("nogeolocation");
$.mobile.loading('hide');
}
},
Expand Down Expand Up @@ -23742,7 +23741,7 @@ Artbot.footerSlider = {

} else {
// We removed all the favorites; show the "no favorites yet" message
$("#footer-slider-msg-nofavorites").fadeIn(400);
Artbot.footerSlider.showErrorMsg("nofavorites");
}
},
reload: function() {
Expand All @@ -23755,6 +23754,15 @@ Artbot.footerSlider = {

}
},
showErrorMsg: function(errorID) {
$("#footer-slider").fadeOut( 400, function() {
$("#footer-slider-msg-"+errorID).fadeIn(400);
$("#footer-slider").show();
});
},
showGeolocationError: function() {
Artbot.footerSlider.showErrorMsg("nogeolocation");
},
destroy: function() {
if (($("#footer-slider").length > 0) && (Artbot.footerSlider.vars.footSlideInstance !== "")) {
console.log("Destroying footer slider");
Expand Down Expand Up @@ -25530,7 +25538,7 @@ Artbot.geolocation = {
Artbot.geolocation.vars.currentLongitude = position.coords.longitude;
Artbot.geolocation.successCallback();
},
showError: function() {
showError: function(error) {
console.log("Geolocation error:");
switch(error.code) {
case error.PERMISSION_DENIED:
Expand Down
6 changes: 3 additions & 3 deletions _source/ui/js/scripts-concat.min.js

Large diffs are not rendered by default.

30 changes: 19 additions & 11 deletions _source/ui/js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ Artbot.footerSlider = {
Artbot.footerSlider.initSlider();
} else {
// No favorites returned, show the "no favorites yet" message
$("#footer-slider-msg-nofavorites").fadeIn(400);
Artbot.footerSlider.showErrorMsg("nofavorites");
}
},
error: function (jqXHR, error, errorThrown) {
Expand All @@ -470,7 +470,7 @@ Artbot.footerSlider = {
} else {

// User is not logged in, show the appropriate message
$("#footer-slider-msg-favoritesignup").fadeIn(400);
Artbot.footerSlider.showErrorMsg("favoritesignup");

}
} else if ($("#venue-events-slider").length > 0) {
Expand Down Expand Up @@ -505,7 +505,7 @@ Artbot.footerSlider = {
Artbot.footerSlider.initSlider();
} else {
// No events returned, show the "no events" message
$("#footer-slider-msg-noevents").fadeIn(400);
Artbot.footerSlider.showErrorMsg("noevents");
}
},
error: function (jqXHR, error, errorThrown) {
Expand Down Expand Up @@ -547,8 +547,7 @@ Artbot.footerSlider = {
Artbot.footerSlider.cycleRelatedInterests(Artbot.var.relatedInterests);

} else {
// TODO: Show error for no results
$("#footer-slider-msg-noevents").fadeIn(400);
Artbot.footerSlider.showErrorMsg("noevents");
}

} else if ($("#near-you-slider").length > 0) {
Expand All @@ -557,7 +556,7 @@ Artbot.footerSlider = {
console.log("Initializing Near You slider");

// First, we have to try to get the user's current position.
Artbot.geolocation.getLocation(Artbot.footerSlider.processNearbyEvents, Artbot.footerSlider.hideFooter);
Artbot.geolocation.getLocation(Artbot.footerSlider.processNearbyEvents, Artbot.footerSlider.showGeolocationError);

}
},
Expand Down Expand Up @@ -597,7 +596,7 @@ Artbot.footerSlider = {
} else {
// No events returned, show the "no events in radius" message
$("#location-radius").html(Artbot.footerSlider.vars.locationRadius);
$("#footer-slider-msg-noeventsnearby").fadeIn(400);
Artbot.footerSlider.showErrorMsg("noeventsnearby");
}
},
error: function (jqXHR, error, errorThrown) {
Expand All @@ -610,8 +609,8 @@ Artbot.footerSlider = {
}
});
} else {
// Couldn't get a position; hide footer
Artbot.footerSlider.hideFooter();
// Couldn't get a position; show error message
Artbot.footerSlider.showErrorMsg("nogeolocation");
$.mobile.loading('hide');
}
},
Expand Down Expand Up @@ -754,7 +753,7 @@ Artbot.footerSlider = {

} else {
// We removed all the favorites; show the "no favorites yet" message
$("#footer-slider-msg-nofavorites").fadeIn(400);
Artbot.footerSlider.showErrorMsg("nofavorites");
}
},
reload: function() {
Expand All @@ -767,6 +766,15 @@ Artbot.footerSlider = {

}
},
showErrorMsg: function(errorID) {
$("#footer-slider").fadeOut( 400, function() {
$("#footer-slider-msg-"+errorID).fadeIn(400);
$("#footer-slider").show();
});
},
showGeolocationError: function() {
Artbot.footerSlider.showErrorMsg("nogeolocation");
},
destroy: function() {
if (($("#footer-slider").length > 0) && (Artbot.footerSlider.vars.footSlideInstance !== "")) {
console.log("Destroying footer slider");
Expand Down Expand Up @@ -2542,7 +2550,7 @@ Artbot.geolocation = {
Artbot.geolocation.vars.currentLongitude = position.coords.longitude;
Artbot.geolocation.successCallback();
},
showError: function() {
showError: function(error) {
console.log("Geolocation error:");
switch(error.code) {
case error.PERMISSION_DENIED:
Expand Down

0 comments on commit a09d1bc

Please sign in to comment.