snappymail/dev/Stores/User/Quota.js
RainLoop Team aa84077ac4 Sound notification
Additional code refactoring
2015-01-27 01:06:00 +04:00

44 lines
658 B
JavaScript

(function () {
'use strict';
var
window = require('window'),
ko = require('ko')
;
/**
* @constructor
*/
function QuotaUserStore()
{
this.quota = ko.observable(0);
this.usage = ko.observable(0);
this.percentage = ko.computed(function () {
var
iQuota = this.quota(),
iUsed = this.usage()
;
return 0 < iQuota ? window.Math.ceil((iUsed / iQuota) * 100) : 0;
}, this);
}
/**
* @param {number} iQuota
* @param {number} iUsage
*/
QuotaUserStore.prototype.populateData = function(iQuota, iUsage)
{
this.quota(iQuota * 1024);
this.usage(iUsage * 1024);
};
module.exports = new QuotaUserStore();
}());