﻿// namespace atlas
var atlas = atlas || {};

// class LoadingIndicator
atlas.LoadingIndicator = function(imageUrl, text) {

	// copy for closure
	var self = this; 
	
	//// Private member vars ////
	var _container = "#loading-indicator-container";
	
	//// Private member functions ////	
	
	//// Public variables & methods ////
	var pub = {
		/**
		* The image, probably an animated gif
		*/
		setImageUrl: function(url) {
			$(_container + " img").attr("src", url);
		},

		getImageUrl: function() {
			return $(_container + " img").attr("src");
		},

		/**
		* Optional text to be displayed next to the image
		*/
		setText: function(txt) {
			$(_container + " span").html(txt);
		},

		getText: function() {
			return $(_container + " span").html();
		},

		/**
		* Displays the loading indicator
		*/
		show: function() {
			$(_container).show();
		},

		/**
		* Hides the loading indicator
		*/
		hide: function() {
			$(_container).hide();
		}
	}
	
	//// Constructor ////
	if (typeof (imageUrl) != "undefined") {
		pub.setImageUrl(imageUrl);
	}
	if (typeof (text) != "undefined") {
		pub.setText(text);
	}
	
	return pub;
}

