/**
* 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
*/
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.theHTML = "";
this._imageDialog = null;
this._profileDialog = null;
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._topLevelSearch = document.getElementById('fcNavSearchBox').innerHTML.replace("fcSearchInput","fcSearchInputBlog");
this._getProfileOverview(true);
};
FIRSTCLASS.apps.Profile.prototype.configure = function() {
FIRSTCLASS.ui.leftSideBar.hide();
FIRSTCLASS.ui.rightSideBar.hide();
this._config.onready();
var that = this;
var whosProfile = "";
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("" + this._topLevelSearch + " | ");
tmp.push("" + this._topLevelMenu.innerHTML + " | ");
tmp.push(" ");
tmp.push("");
if (!this._MyProfile) {
var whichText = FIRSTCLASS.util.BuddyList.isBuddy(this._config.params.uid) ? FIRSTCLASS.locale.profile.stopFollow : FIRSTCLASS.locale.profile.follow;
tmp.push(" | ");
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("");
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);
}
this._getGroupHierarchy();
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) {
if (data == "stats") {
var reads = document.getElementById('totalReads');
if (reads) {
reads.innerHTML = contents.lConfPosts + ' ' + FIRSTCLASS.locale.blog.posts + ', ' + contents.lConfHits + ' ' + FIRSTCLASS.locale.blog.views;
}
}
},
filter: function(dataname) {
if (dataname == "stats") {
return true;
} else {
return false;
}
}
});
this.loadApplication("Blog", false);
};
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 langDiv;
var OldProfileData = FIRSTCLASS.ui.Dom.getChildByIdName('fcProfileUserData',that._resumeDomElement);
var newDiv = document.createElement('div');
newDiv.innerHTML = o.responseText;
var langExtension = YAHOO.util.Cookie.get('fcislang');
if ((langExtension===null) || (langExtension == 'en')) {
langDiv = FIRSTCLASS.ui.Dom.getChildByIdName('fr_language',newDiv);
} else {
langDiv = FIRSTCLASS.ui.Dom.getChildByIdName('en_language',newDiv);
}
langDiv.innerHTML = "