Skip to content

Commit

Permalink
Fixed country-region-selector issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyangel committed Dec 9, 2015
1 parent 0b6c518 commit 73c3b93
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 49 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "trackmapper",
"name": "rikitraki",
"private": true,
"dependencies": {
"bootstrap": "~3.3.4",
Expand Down
25 changes: 12 additions & 13 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<!-- End of domain verification, do not remove -->

<title>RikiTraki</title>
<meta name="description" content="Welcome to RikiTraki, a personal hiking log. Feel free to use the slippy map to explore our hiking experiences and learn more about their locations.">
<meta name="keywords" content="maps,hiking,travel,leaflet,gps,gpx">
<meta name="description" content="Welcome to RikiTraki, a GPS track sharing site. Feel free to use the slippy map to explore our hiking experiences and learn more about their locations.">
<meta name="keywords" content="maps,hiking,biking,travel,leaflet,cesiumjs,gps,gpx">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta property="og:image" content="http://rikitraki.com/images/hikinglg.png" />
<link rel="shortcut icon" href="/favicon.ico">
Expand Down Expand Up @@ -494,7 +494,7 @@ <h4 class="modal-title">Track upload</h4>
</select>
</div>
<div class="col-sm-5">
<select class="form-control" data-default-value="" data-show-default-option="false" id="track-region">
<select class="form-control" id="track-region">
</select>
</div>

Expand Down Expand Up @@ -847,7 +847,7 @@ <h4 class="modal-title">Track details not available</h4>
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3 class="modal-title">RikiTraki</h3><b>v0.5.0<sup>Beta</sup> by Ricardo Morin</b>
<h3 class="modal-title">RikiTraki</h3><b>v0.5.1<sup>Beta</sup> by Ricardo Morin</b>
</div>
<div class="modal-body">
<h4>About this site</h4>
Expand Down Expand Up @@ -887,6 +887,7 @@ <h4>Building blocks</h4>
<li><a href="http://joequery.github.io/Stupid-Table-Plugin/" target="_blank">Stupid-table-plugin</a> super simple table sort plug-in</li>
<li><a href="https://github.com/blueimp/JavaScript-Canvas-to-Blob/" target="_blank">JavaScript Canvas to Blob</a> polyfill for standard canvas.toBlob method</li>
<li><a href="https://github.com/benkeen/country-region-selector/" target="_blank">Country-Region-Selector</a> utility for selecting coordinated country/region</li>
<li><a href="https://github.com/RubaXa/Sortable" target="_blank">RubaXa Sortable</a> library for drag n'drop support</li>
<li><a href="http://publicdomainvectors.org/" target="_blank">publicdomainvectors.org</a> public domain icons</li>
</ul>
<b>Base maps:</b>
Expand Down Expand Up @@ -951,21 +952,19 @@ <h4>Building blocks</h4>
</div>

<!-- bower:js -->
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="bower_components/leaflet/dist/leaflet.js"></script>
<script src="bower_components/leaflet/dist/leaflet-src.js"></script>
<script src="bower_components/leaflet-omnivore/leaflet-omnivore.js"></script>
<script src="bower_components/d3/d3.js"></script>
<script src="bower_components/leaflet-omnivore/leaflet-omnivore.min.js"></script>
<script src="bower_components/d3/d3.min.js"></script>
<script src="bower_components/leaflet.elevation/dist/Leaflet.Elevation-0.0.4.min.js"></script>
<script src="bower_components/leaflet.elevation/dist/Leaflet.Elevation-0.0.4.src.js"></script>
<script src="bower_components/Leaflet.MakiMarkers/Leaflet.MakiMarkers.js"></script>
<script src="bower_components/leaflet.markercluster/dist/leaflet.markercluster-src.js"></script>
<script src="bower_components/leaflet.markercluster/dist/leaflet.markercluster.js"></script>
<script src="bower_components/spin.js/spin.js"></script>
<script src="bower_components/jquery-stupid-table/stupidtable.min.js"></script>
<script src="bower_components/lightbox2/dist/js/lightbox.js"></script>
<script src="bower_components/lightbox2/dist/js/lightbox.min.js"></script>
<script src="bower_components/exif-js/exif.js"></script>
<script src="bower_components/blueimp-canvas-to-blob/js/canvas-to-blob.js"></script>
<script src="bower_components/blueimp-canvas-to-blob/js/canvas-to-blob.min.js"></script>

<!-- endbower -->
<script src="bower_components/country-region-selector/dist/jquery.crs.min.js"></script>
Expand Down
12 changes: 0 additions & 12 deletions js/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,6 @@ var tmData = {
error: errorCallback
});
},
validateEmail: function (email, successCallback, errorCallback) {
$.ajax({
url: 'https://api.mailgun.net/v3/address/validate',
type: 'GET',
data: {address: email},
username: 'api',
password: 'pubkey-006969454903b02211a68c07550724b2',
dataType: 'jsonp',
success: successCallback,
error: errorCallback
});
},
updateUserProfile: function (reg, username, password, successCallback, errorCallback) {
$.ajax({
url: API_BASE_URL + '/v1/users/me',
Expand Down
67 changes: 45 additions & 22 deletions js/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ var tmForms = {
var reg = {};
reg.email = $('#inv-email').val();

// Use mailgun email validation to improve chances of delivery
if (tmUtils.isValidEmail(reg.email)) {
tmData.addInvitation(reg, function() {
$('#invitationError').hide();
Expand Down Expand Up @@ -471,6 +470,10 @@ var tmForms = {
// $('#uploadTrackButton').append('<li><a role="button" id="upload-btn" title="Upload track" href="."><span class="glyphicon glyphicon-cloud-upload" aria-hidden="true"></span></a></li>');
$('#uploadEditContainer').append('<li><a role="button" id="upload-btn" title="Upload track" href="."><span class="glyphicon glyphicon-cloud-upload" aria-hidden="true"></span></a></li>');
$('#upload-btn').click(function() {
// Needed to fix crs annoying issue
$('#track-country').attr('data-crs-loaded', 'false');
window.crs.init();

$('#uploadTrackModal').modal('show');
return false;
});
Expand Down Expand Up @@ -505,7 +508,6 @@ var tmForms = {
// Enable drag and drop sorting
$('#track-photos-container').sortable();
});

},
uploadTrack: function () {
var self = this;
Expand Down Expand Up @@ -568,7 +570,6 @@ var tmForms = {
for (var j=0; j<images.length; j++) {
// Grab original file index (in case list was reordered)
var i = $('#track-photos-container').children()[j].getAttribute('orig-file-index');
console.log(j, i);
// But first resize the image if it is big
if (files[i].size > MAX_IMAGE_SIZE) {
resizeToBlobTasks.push(self.resizeToBlob(data.trackId, images[j], j, uploadPictureTasks));
Expand Down Expand Up @@ -697,16 +698,19 @@ var tmForms = {
// Set current values on the form for editing
$('#edit-track-name').val(track.trackName);
$('#edit-track-description').val(track.trackDescription);
$('#edit-track-activity').val(track.trackType);
$('#edit-track-activity').val(track.trackType ? track.trackType : 'Hiking'); // For compatibility with old data
$('#edit-track-level[value=' + track.trackLevel + ']').prop('checked', true);
if (track.trackFav) {
$('#edit-track-favorite').prop('checked', true);
}
if (track.trackRegionTags[0]) {
var country = track.trackRegionTags[0];
$('#edit-track-country').attr('data-default-value', (country === 'US') ? 'United States' : country);

// Needed to fix crs annoying issue
$('#edit-track-country').attr('data-crs-loaded', 'false');
window.crs.init();

if (track.trackRegionTags[1]) {
$('#edit-track-region').val(track.trackRegionTags[1]);
}
Expand Down Expand Up @@ -737,6 +741,7 @@ var tmForms = {
onAdd: function(evt) {evt.item.remove(); $('#edit-track-file-selector').show();}
});

$('#saveButton').removeAttr('disabled');
$('#editTrackModal').modal('show');
return false;
});
Expand Down Expand Up @@ -798,6 +803,25 @@ var tmForms = {
},
saveEditedTrackInfo: function(track) {
var self = this;
// A couple of private functions
function deletePicture (picIndex) {
return tmData.deleteTrackPic(track.trackId, picIndex, localStorage.getItem('rikitraki-token'));
}

function updateTrack(t) {
tmData.updateTrack(t, localStorage.getItem('rikitraki-token'), function(data) {
$('#savingMessage').hide();
$('#editMessage').fadeIn('slow');
setTimeout(function () {
window.location.href='?track=' + data.trackId;
}, 2000);
}, function(jqxhr) { // jqxhr, textStatus
$('#editErrorText').text('Save error, status ' + jqxhr.status + ' - ' + jqxhr.responseText);
$('#editError').fadeIn('slow');
console.log(jqxhr);
});
}

if (self.isValidForm('edit')) {
$('#savingMessage').fadeIn('slow');
$('#saveSpinner').spin({left: '90%'});
Expand Down Expand Up @@ -879,9 +903,7 @@ var tmForms = {

// Schedule delete photos task
var deletePictureTasks = [];
function deletePicture (picIndex) {
return tmData.deleteTrackPic(track.trackId, picIndex, localStorage.getItem('rikitraki-token'));
}

if ($.inArray(true, photosToDelete) >= 0) {
photosChanged = true;
trackChanged = true;
Expand All @@ -892,20 +914,6 @@ var tmForms = {
}
}

function updateTrack(t) {
tmData.updateTrack(t, localStorage.getItem('rikitraki-token'), function(data) {
$('#savingMessage').hide();
$('#editMessage').fadeIn('slow');
setTimeout(function () {
window.location.href='?track=' + data.trackId;
}, 2000);
}, function(jqxhr) { // jqxhr, textStatus
$('#editErrorText').text('Save error, status ' + jqxhr.status + ' - ' + jqxhr.responseText);
$('#editError').fadeIn('slow');
console.log(jqxhr);
});
}

t.hasPhotos = (t.trackPhotos.length === 0) ? t.hasPhotos = false : t.hasPhotos = true;

if (!photosChanged) {
Expand All @@ -922,7 +930,11 @@ var tmForms = {
});
});
});
}
} else {
$('#editTrackModal').modal('hide');
$('#saveSpinner').spin(false);
this.cleanupErrorMarks();
}
}
},
removeTrack: function(trackId) {
Expand All @@ -942,6 +954,8 @@ var tmForms = {
$('#filter-btn').click(function() {
self.cleanupErrorMarks();
$('#filterModal').find('form').trigger('reset');


var filter = localStorage.getItem('rikitraki-filter');
if (filter) {
filter = JSON.parse(filter);
Expand All @@ -964,14 +978,23 @@ var tmForms = {
}
if (filter.country) {
$('#filter-country').attr('data-default-value', (filter.country === 'US') ? 'United States' : filter.country);

// Needed to fix crs annoying issue
$('#filter-country').attr('data-crs-loaded', 'false');
window.crs.init();
}
if (filter.region) {
$('#filter-region').val(filter.region);
}
} else {
// Needed to fix crs annoying issue
$('#filter-country').attr('data-crs-loaded', 'false');
window.crs.init();
}

// Below needed to fix annoying crs issue


var me = localStorage.getItem('rikitraki-username');
if (me) {
$('#filter-me').removeAttr('disabled');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rikitraki",
"version": "0.1.1",
"version": "0.5.1",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-bower": "^0.19.0",
Expand Down

0 comments on commit 73c3b93

Please sign in to comment.