/**
* Class Description
* @namespace FIRSTCLASS.apps
* @module Profile
* @requires
* @optional
* @title User Profile
*/
/**
* Constructor definition
* @class Profile
* @constructor
* @param {Object} config (required) the configuration object
* @param {string|HTMLElement} config.div (required) the div to load into
* @param {string} config.baseUrl (required) the container base url
*/
FIRSTCLASS.apps.Profile = function(config) {
/**
* Private member variables
*
* Private variables are identified by the convention of naming them with a leading underscore.
* i.e. this._privateVariable
*/
var that = this;
this._subApps = [
{label:"Overview", app:"fcOverview", loaded:true },
{label:"Blog", app:"fcBlog", loaded:false}
];
this._dataSource = null;
this._title = "Profile";
this._listView = null;
this._uploadImageStep = 0;
this._convertStep = 0;
this._initalpadding = 0;
this._blankProfile = false;
this._createProfile = false;
this._inEditMode = false;
this._parentDiv = config.parentDiv;
this._config = config;
if (typeof config.params.uid == "string") {
if (config.params.uid.indexOf("CID") == 0)
this._config.params.cid = config.params.uid;
else
this._config.params.cid = "CID" + config.params.uid;
} else {
this._config.params.cid = "CID" + config.params.uid;
}
// session.user.cid is actually the uid
this._MyProfile = (this._config.params.uid == FIRSTCLASS.session.user.cid);
this._baseURL = config.baseUrl;
this._domElement = (typeof(this._config.div) == "string") ? document.getElementById(this._config.divId) : this._config.div;
this._topLevelMenu = document.getElementById('topLevelMenu');
this._getProfileOverview(true);
this.activate();
};
FIRSTCLASS.apps.Profile.prototype.configure = function() {
FIRSTCLASS.ui.leftSideBar.hide();
FIRSTCLASS.ui.rightSideBar.hide();
this._config.onready();
var that = this;
var whosProfile = "";
var blogNavBar;
var tmp = [];
if ((typeof this._config.params.name == 'undefined') || (this._config.params.name == 'undefined'))
this._config.params.name = "";
if (this._MyProfile )
whosProfile = FIRSTCLASS.locale.blog.myBlog;
else if (this._config.params.name != "")
whosProfile = FIRSTCLASS.locale.doSub(FIRSTCLASS.locale.blog.othersBlog,{whosProfile:this._config.params.name});
tmp.push("
| ");
tmp.push ("");
tmp.push (" | ");
tmp.push("");
tmp.push("");
if (!this._MyProfile) {
tmp.push(" | ");
tmp.push("");
tmp.push(" | ");
}
tmp.push(" | | | | ");
tmp.push(" | | ");
tmp.push(" | ");
tmp.push("");
tmp.push(" |
");
FIRSTCLASS.ui.navBar.clearContentPane();
this._domElement.innerHTML = tmp.join("");
if (blogNavBar)
FIRSTCLASS.ui.initializeSearchBox('fcSearchInputBlog');
this._resumeDomElement = document.getElementById("fcProfileOverview");
var mainTable = document.getElementById("fcMain");
YAHOO.util.Dom.addClass(mainTable, "fcAppScrollingContent");
YAHOO.util.Dom.setStyle(mainTable, "overflow", "auto");
var url = this._config.baseUrl;
if (this._config.params.itemthread && (this._config.params.itemthread != "") && this._config.params.messageid && (this._config.params.messageid != "")) {
url = url + "TD-" + this._config.params.itemthread + "-" + this._config.params.messageid.replace(":","-").substr(1,this._config.params.messageid.length-2);
}
FIRSTCLASS.session.addHistoryEntry({
"uri": url,
"app": this,
activate: function()
{
that.activate();
}
});
this._singleThreadView = (typeof this._config.params.itemthread == 'string');
this._dataSource = new FIRSTCLASS.util.DataSource({
containerBaseUrl: this._config.baseUrl,
autoLoad: false, // !this._singleThreadView,
watchForNew: !this._singleThreadView,
loadUnreadImmediate: false,
docbodies:false,
nosymbiomainfetch: true,
messagebodies:false,
serversort: "&Table=-3_9",
fetchThreads: true,
fetchThreadID: this._singleThreadView ? this._config.params.itemthread : false
});
this._dataSource.addRowListener({
onRow: function(row, dataSource) { that._config.onLoaded(); },
onFillCompleted: function(dataSource) {
that._subApps[1].instance.emptyBlogCheck(that._MyProfile,this._singleThreadView);
}
});
this._dataSource.addDataListener({
onHeaderData:function(data, contents) {
switch (data) {
case "stats":
document.getElementById('totalReads').innerHTML = contents.lConfPosts + ' ' + FIRSTCLASS.locale.blog.posts + ', ' + contents.lConfHits + ' ' + FIRSTCLASS.locale.blog.views;
default:
}
},
filter: function(dataname) {
switch (dataname) {
case "stats":
return true;
default:
return false;
}
}
});
this.loadApplication("Blog", false);
this._isMyBuddy = FIRSTCLASS.util.BuddyList.isBuddy(that._config.params.uid);
};
FIRSTCLASS.apps.Profile.prototype.handleEvent = function(evt, fcevent) {
var rv = false;
var app;
for (var i in this._subApps) {
app = this._subApps[i];
if (app.instance && app.instance != this && app.instance._listView) {
rv = app.instance._listView.handleEvent(evt, fcevent);
if (rv) {
break;
}
}
}
return rv;
};
FIRSTCLASS.apps.Profile.prototype.isSafeToNavigate = function() {
return (this._subApps[1].instance._editor === null) && (this._subApps[1].instance._myFeed.message === null);
};
FIRSTCLASS.apps.Profile.prototype.overrideSafeToNavigate = function() {
if (this._subApps[1].instance._editor != null)
this._subApps[1].instance._editor._editor.onCancel();
if (this._subApps[1].instance._myFeed.message != null)
this._subApps[1].instance._myFeed.message.onCancel();
}
FIRSTCLASS.apps.Profile.prototype._updateProfileOverview = function ()
{
var that = this;
var handleSuccess = function(o) {
if(typeof o.responseText !== 'undefined') {
var OldProfileData = FIRSTCLASS.ui.Dom.getChildByIdName('fcProfileUserData',that._resumeDomElement)
var newDiv = document.createElement('div');
newDiv.innerHTML = o.responseText;
var newProfileData = FIRSTCLASS.ui.Dom.getChildByIdName('fcProfileUserData',newDiv);
OldProfileData.innerHTML = newProfileData.innerHTML;
that._setupProfileLinks(that._resumeDomElement);
domElem = document.getElementById("fcProfileResume");
that.createSearchLinks(domElem);
var userName = document.getElementById('fcProfileUserName');
if (that._config.params.name == "")
userName.innerHTML = document.getElementById('blogOwner').innerHTML;
else
userName.innerHTML = that._config.params.name;
that.resizeEvent();
}
};
var handleFailure = function(o){
if(typeof o.responseText !== 'undefined') {
alert(FIRSTCLASS.locale.profile.noRetrieve);
}
};
var callback = {
success:handleSuccess,
failure: handleFailure
};
var theURL = (this._MyProfile) ? FIRSTCLASS.session.baseURL + "__Open-Item/SharedDocuments/FCXResume" : that._config.baseUrl + "FCXResume";
var request = YAHOO.util.Connect.asyncRequest('GET', theURL+"?Close=0", callback);
}
FIRSTCLASS.apps.Profile.prototype.updateStatusInfo = function() {
var userName = document.getElementById('fcProfileUserName');
if (this._config.params.name == "") {
userName.innerHTML = document.getElementById('blogOwner').innerHTML;
document.getElementById('whosProfile').innerHTML = FIRSTCLASS.locale.doSub(FIRSTCLASS.locale.blog.othersBlog,{whosProfile:userName.innerHTML});
} else
userName.innerHTML = this._config.params.name;
var statusDom = document.getElementById("fcProfileRightStatus");
if (statusDom != null) {
var tmp = [];
var statMsg = document.getElementById("blogStatusMsg").innerHTML;
var statTime = parseInt(document.getElementById("blogStatusTime").innerHTML);
var isOnline = document.getElementById("blogOnline").innerHTML;
if (!this._MyProfile) {
if (statMsg == "") {
if (isOnline=="1")
statMsg = userName.innerHTML + ' ' + FIRSTCLASS.locale.profile.currOnline;
else if (isOnline=="0")
statMsg = userName.innerHTML + ' ' + FIRSTCLASS.locale.profile.currOffline;
else
statMsg = userName.innerHTML + ' ' + FIRSTCLASS.locale.profile.noStatMsg;
}
tmp.push("