/**
 * Created by Gayan on 12/17/15.
 */
angular.module('app.services')
  .factory('LoadingMsg', ['$ionicLoading','$interval','$timeout', function ( $ionicLoading,$interval,$timeout) {
    return {
      showLoading : function() {
      var progressLine=".";
      var intervalPercentage=$interval(function () {
        $ionicLoading.show({
          template: '<div class="nf-center nf-valign-wrapper"><ion-spinner icon="ripple" class="nf-text-white"></ion-spinner>' +
          '<span>Please wait '+progressLine+'</span></div>'
        });
        if(progressLine.length >= 10){
          progressLine=".";
        }
        progressLine+=".";
      }, 1000);
      return intervalPercentage;
    }, hideLoading : function(intervalPercentage) {
      $timeout(function () {
        $interval.cancel(intervalPercentage);
        $ionicLoading.hide();
      }, 1000);
    }
  };
}]);
