angular
        .module('carfriend')
        .factory('LoadingService', loadingService);

function loadingService($ionicLoading) {
    var isLoading;
    var services = {
        startLoad: startLoad,
        completeLoad: completeLoad,
        isLoadingNow: isLoadingNow
    };

    return services;

    /////////
    
    function startLoad() {
        isLoading = true;
        $ionicLoading.show({
            content: 'Načítavam',
            showBackdrop: true,
            hideOnStateChange: true,
            maxWidth: 200,
            showDelay: 0,
            template: '<ion-spinner icon="ripple"/>'
        });
    }
    ;

    function completeLoad() {
        isLoading = false;
        $ionicLoading.hide();
    }
    ;
    
    function isLoadingNow(){
        return isLoading;
    }

}
;

