LoadMask.js 1.07 KB
Ext.define('treps.LoadMask', {
	singleton : true,

	runner: new Ext.util.TaskRunner(),

	show : function(msg)
	{
		Ext.getBody().mask(msg);
	},

	showStatus : function(statusDirectAPI)
	{
		var msg = 'Processing... Please wait <br/>';

		var mask = Ext.getBody().mask(msg);

		var task = this.runner.newTask({
			run: function () {
				//
				if (statusDirectAPI)
				{
					statusDirectAPI.call(this,{'id' : treps.model.Session.get('id')}, function(result, event)
						{
							var statusMsg;
							if (result && result.success)
								statusMsg = result.status;
							else
								statusMsg = 'Unknown status';

							var maskMsg = Ext.DomQuery.select('div[class=x-mask-msg-text]');

							if (maskMsg)
								maskMsg = maskMsg[0];
							else
								return;

							Ext.fly(maskMsg).update(msg+result.status)
						});
				}
			},
			interval: 3000
		});

		task.start();
	},
	
	hide : function()
	{
		this.runner.stopAll();
		Ext.getBody().unmask();
	},
	
	isMasked : function()
    {
		return Ext.getBody().isMasked();
	}
});