Skip to content

Commit

Permalink
Merge pull request #16 from hootsuite/DEVP-263-plugin-geolocation-iframe
Browse files Browse the repository at this point in the history
DEVP-263 Added geolocation test feature for plugin
  • Loading branch information
jody-chambers-hs committed Apr 25, 2018
2 parents 8e86ce4 + 507a7ed commit 1c0663a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
4 changes: 4 additions & 0 deletions assets/modal.js
Expand Up @@ -117,6 +117,10 @@ function startEventListeners() {
replaceTextInClass('hs_copyJsonButton', 'Copied!');
});

getSingleElementByClassName('hs_showGeolocation').addEventListener('click', function () {
getGeolocation();
});

// sets up dropdown menu
var topBarControl = getSingleElementByClassName('hs_topBarControlsBtn');
topBarControl.addEventListener('click', function (event) {
Expand Down
14 changes: 0 additions & 14 deletions assets/stream.js
Expand Up @@ -157,20 +157,6 @@ function loadTopBars() {
});
}

function getGeolocation() {
function success(pos) {
let coords = pos.coords;
let lngLat = coords.longitude + ' ' + coords.latitude;
replaceTextInClass('hs_showGeolocation', lngLat);
}
function error(err) {
replaceTextInClass('hs_showGeolocation', 'No location');
alert('Could not get Geolocation. Check your browser location privacy settings.', err);
}
replaceTextInClass('hs_showGeolocation', 'Loading...');
navigator.geolocation.getCurrentPosition(success, error);
}

// for our purposes this is the same thing as jQuery's $(document).ready(...)
document.addEventListener('DOMContentLoaded', function () {
// intializes the Hootsuite JS SDK
Expand Down
14 changes: 14 additions & 0 deletions assets/util.js
Expand Up @@ -104,3 +104,17 @@ function googleAuthInit() {
}
});
}

function getGeolocation() {
function success(pos) {
let coords = pos.coords;
let lngLat = coords.longitude + ' ' + coords.latitude;
replaceTextInClass('hs_showGeolocation', lngLat);
}
function error(err) {
replaceTextInClass('hs_showGeolocation', 'No location');
alert('Could not get Geolocation. Check your browser location privacy settings.', err);
}
replaceTextInClass('hs_showGeolocation', 'Loading...');
navigator.geolocation.getCurrentPosition(success, error);
}
3 changes: 3 additions & 0 deletions modal.html
Expand Up @@ -71,6 +71,9 @@ <h1 class="hs_topBarTitle">Hootsuite Component Sample</h1>
</ul>
</div>
</div>
<button class="hs_btnCtaSml hs_btnTypeSubmit hs_showGeolocation">
showGeolocation()
</button>
<button class="hs_btnCtaSml hs_btnTypeCta hs_showJsonButton">
Show JSON Payload
</button>
Expand Down

0 comments on commit 1c0663a

Please sign in to comment.