The final commit personal address books branches before merging

This commit is contained in:
RainLoop Team 2013-12-07 01:50:19 +04:00
parent 43f094220c
commit 867dcc8f7e
44 changed files with 2163 additions and 1147 deletions

View file

@ -6,26 +6,65 @@
function ContactModel()
{
this.idContact = 0;
this.imageHash = '';
this.listName = '';
this.name = '';
this.emails = [];
this.display = '';
this.properties = [];
this.checked = ko.observable(false);
this.selected = ko.observable(false);
this.deleted = ko.observable(false);
}
/**
* @return {Array|null}
*/
ContactModel.prototype.getNameAndEmailHelper = function ()
{
var
sName = '',
sEmail = ''
;
if (Utils.isNonEmptyArray(this.properties))
{
_.each(this.properties, function (aProperty) {
if (aProperty)
{
if ('' === sName && Enums.ContactPropertyType.FullName === aProperty[0])
{
sName = aProperty[1];
}
else if ('' === sEmail && -1 < Utils.inArray(aProperty[0], [
Enums.ContactPropertyType.EmailPersonal,
Enums.ContactPropertyType.EmailBussines,
Enums.ContactPropertyType.EmailOther
]))
{
sEmail = aProperty[1];
}
}
}, this);
}
return '' === sEmail ? null : [sEmail, sName];
};
ContactModel.prototype.parse = function (oItem)
{
var bResult = false;
if (oItem && 'Object/Contact' === oItem['@Object'])
{
this.idContact = Utils.pInt(oItem['IdContact']);
this.listName = Utils.pString(oItem['ListName']);
this.name = Utils.pString(oItem['Name']);
this.emails = Utils.isNonEmptyArray(oItem['Emails']) ? oItem['Emails'] : [];
this.imageHash = Utils.pString(oItem['ImageHash']);
this.display = Utils.pString(oItem['Display']);
if (Utils.isNonEmptyArray(oItem['Properties']))
{
_.each(oItem['Properties'], function (oProperty) {
if (oProperty && oProperty['Type'] && Utils.isNormal(oProperty['Value']))
{
this.properties.push([Utils.pInt(oProperty['Type']), Utils.pString(oProperty['Value'])]);
}
}, this);
}
bResult = true;
}
@ -38,8 +77,7 @@ ContactModel.prototype.parse = function (oItem)
*/
ContactModel.prototype.srcAttr = function ()
{
return '' === this.imageHash ? RL.link().emptyContactPic() :
RL.link().getUserPicUrlFromHash(this.imageHash);
return RL.link().emptyContactPic();
};
/**

View file

@ -0,0 +1,73 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function ContactModel()
{
this.idContact = 0;
this.imageHash = '';
this.listName = '';
this.name = '';
this.emails = [];
this.checked = ko.observable(false);
this.selected = ko.observable(false);
this.deleted = ko.observable(false);
}
ContactModel.prototype.parse = function (oItem)
{
var bResult = false;
if (oItem && 'Object/Contact' === oItem['@Object'])
{
this.idContact = Utils.pInt(oItem['IdContact']);
this.listName = Utils.pString(oItem['ListName']);
this.name = Utils.pString(oItem['Name']);
this.emails = Utils.isNonEmptyArray(oItem['Emails']) ? oItem['Emails'] : [];
this.imageHash = Utils.pString(oItem['ImageHash']);
bResult = true;
}
return bResult;
};
/**
* @return {string}
*/
ContactModel.prototype.srcAttr = function ()
{
return '' === this.imageHash ? RL.link().emptyContactPic() :
RL.link().getUserPicUrlFromHash(this.imageHash);
};
/**
* @return {string}
*/
ContactModel.prototype.generateUid = function ()
{
return '' + this.idContact;
};
/**
* @return string
*/
ContactModel.prototype.lineAsCcc = function ()
{
var aResult = [];
if (this.deleted())
{
aResult.push('deleted');
}
if (this.selected())
{
aResult.push('selected');
}
if (this.checked())
{
aResult.push('checked');
}
return aResult.join(' ');
};

View file

@ -0,0 +1,14 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @param {number=} iType = Enums.ContactPropertyType.Unknown
* @param {string=} sValue = ''
*
* @constructor
*/
function ContactPropertyModel(iType, sValue)
{
this.type = ko.observable(Utils.isUnd(iType) ? Enums.ContactPropertyType.Unknown : iType);
this.focused = ko.observable(false);
this.value = ko.observable(Utils.pString(sValue));
}