Skip to content

Instantly share code, notes, and snippets.

@michaeldjeffrey
Last active August 29, 2015 14:13
Show Gist options
  • Save michaeldjeffrey/0e010b70c1a4934a6d51 to your computer and use it in GitHub Desktop.
Save michaeldjeffrey/0e010b70c1a4934a6d51 to your computer and use it in GitHub Desktop.
// when a new profile is loaded, convert the vertices to the new data format
$scope.$on('profileLoadedEvent', function (event) {
ProfileVertexConverterService.convert($scope.profile.vertices).then(function (vertices) {
// do stuff
ModalService.close();
});
});
.service('ModalService', [
'$timeout',
'$modal',
function ($timeout, $modal) {
var modalInstance, isOpen = false;
function open(header) {
if (!isOpen) {
modalInstance = $modal.open({
templateUrl: 'static/views/modal-template.html',
backdrop: 'static',
keyboard: false,
windowClass: 'modal-absolute-center',
controllerAs: 'modal',
controller: function () {
var ctrl = this;
ctrl.header = header || 'Please Wait...';
}
});
isOpen = true;
return modalInstance;
}
}
function close() {
if (angular.isDefined(modalInstance)) {
modalInstance.close();
isOpen = false;
modalInstance = undefined;
}
}
return {
open: open,
close: close
}
}
])
$scope.loadProfile = function (id, onSuccess) {
$q.when(ModalService.open('Loading profile, please wait...')).then(function(){
$scope.$broadcast('profileLoadedEvent');
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment