/** * 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("
![]() | ");
} else {
tmp.push(""); } tmp.push(" | " + FIRSTCLASS.util.expandHashTags(statMsg.parseURLS()) + " | "); if (!isNaN(statTime) && (statTime !== 0)) { tmp.push("
| (" + FIRSTCLASS.util.Date.getFriendlyDateTimeString(FIRSTCLASS.lang.fcTimeToDate(statTime)) + ") |
![]() | ");
tmp.push("");
if ((statTime!==0) && !isNaN(statTime)) {
tmp.push(" (" + FIRSTCLASS.util.Date.getFriendlyDateTimeString(FIRSTCLASS.lang.fcTimeToDate(statTime)) + ")");
}
tmp.push(" |
| " + FIRSTCLASS.locale.profile.ownmissing + " | "); tmp.push("
| ||||||||||||
| " + FIRSTCLASS.locale.profile.othermissing + " | "); tmp.push("
| " + FIRSTCLASS.locale.profile.othermissing + " | "); tmp.push("
" + FIRSTCLASS.locale.editProfile.next;
showhideTD.innerHTML = html;
}
else
{
YAHOO.util.Dom.setStyle(basicStuff,"display","none");
YAHOO.util.Dom.setStyle(extraStuff,"display","");
html = "
" + FIRSTCLASS.locale.editProfile.prev;
showhideTD.innerHTML = html;
}
};
FIRSTCLASS.apps.Profile.prototype.editProfileData = function ()
{
this._bodyDivElement = document.createElement('div');
var msgCfg = {
callback: this,
element: this._bodyDivElement,
objType: FIRSTCLASS.objTypes.formdoc,
formID: 20502,
formElId: "fcProfileOverviewForm",
bodyType: "",
quoteText: null,
sendTo: null,
params: "Clear=0",
op: FIRSTCLASS.opCodes.FormEdit,
baseURL: (this._MyProfile) ? FIRSTCLASS.session.baseURL + "__Open-Item/SharedDocuments/FCXResume" : this._baseUrl + "FCXResume"
};
this._uploadImageStep = 0;
this._editor = new FIRSTCLASS.util.Message(msgCfg);
};
FIRSTCLASS.apps.Profile.prototype.onLoaded = function(isEditable) {
if (!isEditable) {
alert(FIRSTCLASS.locale.profile.noEdit);
this._inEditMode = false;
}
};
FIRSTCLASS.apps.Profile.prototype.validate = function() {
if (this._uploadImageStep === 0) {
return true;
}
if (this._uploadImageStep == 2) {
this._uploadImageStep = 3;
var uploadName = document.getElementById('insertimage_upload');
if (uploadName !== null) {
if (uploadName.value === "") {
this._uploadImageStep = 2;
alert(FIRSTCLASS.locale.profileImageUpload.selectImage);
} else if (uploadName.value.match('.jpg$|.JPG$|.jpeg$|.JPEG$') === null) {
this._uploadImageStep = 2;
alert(FIRSTCLASS.locale.profileImageUpload.onlyJPG);
} else {
YAHOO.util.Dom.setStyle(document.getElementById('uploader_image'),"display","inline");
document.getElementById("whichStep").innerHTML = FIRSTCLASS.locale.profileImageUpload.step1;
YAHOO.util.Dom.setStyle(document.getElementById('completebar'),"display","block");
YAHOO.util.Dom.setStyle(document.getElementById('whichStep'),"display","");
return true;
}
}
return false;
}
return false;
};
FIRSTCLASS.apps.Profile.prototype.onFail = function(o)
{
if (this._uploadImageStep === 0) { // must be profile
alert(FIRSTCLASS.locale.profile.noRetrieve);
} else {
var alertText;
if (o.statusText) {
alertText = FIRSTCLASS.locale.doSub(FIRSTCLASS.locale.profile.failwitherror,{status:o.statusText});
} else {
alertText = FIRSTCLASS.locale.profile.failnoerror;
}
alert(alertText);
this._cleanupUpload(false);
}
this._inEditMode = false;
};
FIRSTCLASS.apps.Profile.prototype.onCancel = function() {
var profileURL = FIRSTCLASS.util.User.getProfileUrlByCid(FIRSTCLASS.session.user.cid);
if (this._uploadImageStep === 0) { // was editing profile, so close it.
FIRSTCLASS.util.net.asyncRequest('GET',profileURL + 'FCXResume?Close=0',{});
this._profileDialog.destroy();
this._profileDialog = null;
this._inEditMode = false;
} else {
if (this._uploadImageStep == 4) { // was editing pic, so delete temp.
FIRSTCLASS.util.net.asyncRequest('GET', profileURL + 'FCXResume/profile_temp.jpg?Delete=1',null);
}
if (this._imageDialog !== null) {
this._imageDialog.destroy();
this._imageDialog = null;
}
this._uploadImageStep = 0;
if (this._profileDialog === null) {
this._inEditMode = false;
}
}
};
FIRSTCLASS.apps.Profile.prototype.onDisplay = function() {
if (this._uploadImageStep == 1) {
this._uploadImageStep = 2;
this.setupImageDialog();
} else {
this._createProfile = false;
this.setupProfileDialog();
}
};
FIRSTCLASS.apps.Profile.prototype.onSave = function()
{
var that = this;
if (this._uploadImageStep == 3) {
this._uploadImageStep = 4;
this._theIMG = FIRSTCLASS.ui.Dom.getChildByClassName('crop1', this._pictureDivElement);
YAHOO.util.Event.addListener(this._theIMG, 'load', function() { that._resizeUploaded(this); } );
this._theIMG.src = FIRSTCLASS.session.baseURL + "__Open-Item/SharedDocuments/FCXResume/profile_temp.jpg?" + FIRSTCLASS.ui.Dom.getCurrTimestamp();
} else {
// this._updateProfileCompleteness(); NO LONGER SHOW PROFILE BARGRAPH
this._profileDialog.destroy();
this._profileDialog = null;
this._inEditMode = false;
this._createProfile = false;
if (this._blankProfile) {
this._getProfileOverview();
} else {
this._updateProfileOverview();
}
this._uploadImageStep = 0;
}
};
FIRSTCLASS.apps.Profile.prototype._updateProfileCompleteness = function()
{
//var tempComplete = {FIRSTCLASS.locale.profileCompleteness.photo:0,FIRSTCLASS.locale.profileCompleteness.bio:0,FIRSTCLASS.locale.profileCompleteness.expertise:0,FIRSTCLASS.locale.profileCompleteness.phone:0,FIRSTCLASS.locale.profileCompleteness.manager:0,FIRSTCLASS.locale.profileCompleteness.im:0,FIRSTCLASS.locale.profileCompleteness.department:0,FIRSTCLASS.locale,profileCompleteness.education:0};
var tempComplete = {"photo":0,"bio":0,"expertise":0,"phone":0,"manager":0,"IM":0,"department":0,"education":0};
var tempCompleteNames = [FIRSTCLASS.locale.profileCompleteness.photo,FIRSTCLASS.locale.profileCompleteness.bio,FIRSTCLASS.locale.profileCompleteness.expertise,FIRSTCLASS.locale.profileCompleteness.phone,FIRSTCLASS.locale.profileCompleteness.manager,FIRSTCLASS.locale.profileCompleteness.im,FIRSTCLASS.locale.profileCompleteness.department,FIRSTCLASS.locale.profileCompleteness.education];
var fieldIDs = ["0","3019","3012","3010","3002","3017","3024","3013"];
var tempInput;
var index = FIRSTCLASS.ui.Dom.getChildByIdName("2017", this._bodyDivElement).value;
if (index > 0) {
tempComplete.IMType = 1;
} else {
tempComplete.IMType = index;
}
for (index=1; index < 8; ++index) {
tempInput = FIRSTCLASS.ui.Dom.getChildByIdName(fieldIDs[index], this._bodyDivElement);
if ((tempInput!==null) && (tempInput.value.length > 0)) {
tempComplete[tempCompleteNames[index]] = 1;
}
}
FIRSTCLASS.session.desktop.updateProfileInfo(tempComplete);
};
FIRSTCLASS.apps.Profile.prototype._resizeUploaded = function(theIMG)
{
var cropperTable = document.getElementById('profile_imagecropper');
YAHOO.util.Dom.setStyle(cropperTable,"display","inline");
this.realImageWidth = theIMG.width;
this.realImageHeight = theIMG.height;
YAHOO.util.Dom.setStyle(cropperTable,"display","none");
var that = this;
var maxSize = 550.0;
var screenSize;
var resizeParam;
if (typeof screen != "undefined") {
screenSize = (screen.width > screen.height) ? screen.height : screen.width;
if ((screenSize * 0.65) < maxSize) {
maxSize = parseInt(maxSize * 0.65,10);
}
}
if ((this.realImageWidth > maxSize) || (this.realImageHeight > maxSize)) {
if (this.realImageWidth > this.realImageHeight) {
this._percentResize = this.realImageWidth / maxSize;
resizeParam = "Width=" + maxSize + "&Height=" + parseInt(this.realImageHeight/this._percentResize,10);
} else {
this._percentResize = this.realImageHeight / maxSize;
resizeParam = "Width=" + parseInt(this.realImageWidth/this._percentResize,10) + "&Height=" + maxSize;
}
} else {
this._percentResize = 1;
resizeParam = "Height=" + this.realImageHeight;
}
YAHOO.util.Event.removeListener(this._theIMG,'load');
YAHOO.util.Event.addListener(this._theIMG, 'load', function() {
that._setupCropper(that._theIMG);
var button = document.getElementById('fcDocFormSave');
YAHOO.util.Dom.setStyle(button,"display","none");
button = document.getElementById('profile_cropbutton');
YAHOO.util.Dom.setStyle(button,"display","inline");
});
this._theIMG.src = this._theIMG.src + "&" + resizeParam;
};
FIRSTCLASS.apps.Profile.prototype._setupCropper = function(theIMG)
{
var that = this;
var initX, initY;
var cropperTable = document.getElementById('profile_imageupload');
document.getElementById("whichStep").innerHTML = FIRSTCLASS.locale.profileImageUpload.step2;
YAHOO.util.Dom.setStyle(document.getElementById("percentage"),"width","40%");
YAHOO.util.Dom.setStyle(cropperTable,"display","none");
cropperTable = document.getElementById('profile_imagecropper');
YAHOO.util.Dom.setStyle(cropperTable,"display","inline");
var cropWidth = theIMG.width;
var cropHeight = theIMG.height;
YAHOO.util.Dom.setStyle(this._imageDialog.element.firstChild,'width',(theIMG.width < 380 ? 400 : theIMG.width + 20) +'px');
if ((cropWidth / cropHeight) > 0.75) {
cropWidth = cropHeight * 0.75;
initX = parseInt((theIMG.width-cropWidth)/2,10);
initY = 0;
} else {
cropHeight = (cropWidth * 4)/3;
initX = 0;
initY = parseInt((theIMG.height-cropHeight)/2,10);
}
this._cropper = new YAHOO.widget.ImageCropper(
'crop1',
{
initialXY: [initX,initY],
initHeight: cropHeight,
initWidth: cropWidth,
keyTick: 5,
shiftKeyTick: 50,
ratio:true
}
);
var cropButton = document.getElementById('profile_cropbutton');
YAHOO.util.Event.addListener(cropButton, 'click', function() { that._saveProfileImages(); });
this._imageDialog.center();
};
FIRSTCLASS.apps.Profile.prototype._saveProfileImages = function()
{
var that = this;
var theURL;
var url135x180;
var origCroppedH;
var coords = this._cropper.getCropCoords();
var clipWithTime;
document.getElementById("whichStep").innerHTML = FIRSTCLASS.locale.profileImageUpload.step3;
YAHOO.util.Event.removeListener(this._theIMG, 'load');
this._theIMG = document.getElementById('resizedImage');
document.getElementById('fcProfilePicture').src = FIRSTCLASS.session.ui.fcbase.absolute + "/images/uploading_ar32x32.gif";
coords.left = parseInt(coords.left * this._percentResize,10);
coords.top = parseInt(coords.top * this._percentResize,10);
coords.width = parseInt(coords.width * this._percentResize,10);
coords.width = coords.width - (coords.width % 3);
origCroppedH = coords.height;
coords.height = parseInt(coords.width * 4,10) / 3;
// ensure that cropper didn't get it "maintain ratio" screwed up
if (coords.height > this.realImageHeight) {
coords.height = parseInt(origCroppedH * this._percentResize,10);
coords.height = coords.height - (coords.height % 4);
coords.width = parseInt(coords.height * 3,10) / 4;
}
var finalWidth = (coords.width > 135) ? 135 : coords.width;
var finalHeight = (coords.height > 180) ? 180 : coords.height;
var sharedFolder = FIRSTCLASS.util.User.getProfileUrlByCid(FIRSTCLASS.session.user.cid);
var httpPart = sharedFolder.indexOf("/Login");
if (httpPart > -1) {
sharedFolder = sharedFolder.substring(httpPart,sharedFolder.length);
}
var handleSuccess = function(o) {
if (that._convertStep == 1) {
document.getElementById("whichStep").innerHTML = FIRSTCLASS.locale.profileImageUpload.step4;
YAHOO.util.Dom.setStyle(document.getElementById("percentage"),"width","60%");
that._convertStep = 2;
theURL = clipWithTime + "&WidthAA=50&HeightAA=67&SaveDest=" + sharedFolder + "FCXResume/profile_50x67.jpg";
that._theIMG.src = theURL;
} else if (that._convertStep == 2) {
document.getElementById("whichStep").innerHTML = FIRSTCLASS.locale.profileImageUpload.step5;
YAHOO.util.Dom.setStyle(document.getElementById("percentage"),"width","80%");
that._convertStep = 3;
theURL = clipWithTime + "&WidthAA=20&HeightAA=27&SaveDest=" + sharedFolder + "FCXResume/profile_20x27.jpg";
that._theIMG.src = theURL;
} else if (that._convertStep == 3) {
YAHOO.util.Dom.setStyle(document.getElementById("percentage"),"width","90%");
that._convertStep = 4;
theURL = clipWithTime + "&SaveDest=" + sharedFolder + "FCXResume/profile_original.jpg";
that._theIMG.src = theURL;
} else if (that._convertStep == 4) {
YAHOO.util.Dom.setStyle(document.getElementById("percentage"),"width","100%");
that._convertStep = 5;
FIRSTCLASS.util.User.updateLatestImageTimestamp();
document.getElementById("fcProfilePicture").src = url135x180;
if (that._profileDialog) {
document.getElementById('editProfilePic').src = url135x180;
}
that._theIMG.src = FIRSTCLASS.util.User.getSmallProfPicUrlByCid(that._config.params.cid);
} else if (that._convertStep == 5) {
// FIRSTCLASS.util.net.asyncRequest('GET',sharedFolder + "FCXResume/profile_temp.jpg?Delete=1", null);
that._cleanupUpload(true);
}
};
var handleFailure = function(o){
document.getElementById('fcProfilePicture').src = "";
if (typeof o.status != 'undefined') {
alert(FIRSTCLASS.locale.doSub(FIRSTCLASS.locale.profileImageUpload.failwitherror,{status:o.status}));
} else {
alert(FIRSTCLASS.locale.profileImageUpload.failnoerror);
}
that._cleanupUpload(true);
};
this._callback = {
success:handleSuccess,
failure: handleFailure
};
this._convertStep = 1;
YAHOO.util.Event.addListener(this._theIMG, 'load', handleSuccess);
YAHOO.util.Event.addListener(this._theIMG, 'abort', handleFailure);
YAHOO.util.Event.addListener(this._theIMG, 'error', handleFailure);
clipWithTime = sharedFolder + "FCXResume/profile_temp.jpg?" + FIRSTCLASS.ui.Dom.getCurrTimestamp() + "&Clip=" + coords.left + "_" + coords.top + "_" + (coords.left + coords.width) + "_" + (coords.top + coords.height);
url135x180 = clipWithTime + "&WidthAA=" + finalWidth + "&HeightAA=" + finalHeight;
theURL = url135x180 + "&SaveDest=" + sharedFolder + "FCXResume/profile_135x180.jpg";
this._theIMG.src = theURL;
};
FIRSTCLASS.apps.Profile.prototype._cleanupUpload = function(removeListen)
{
if (removeListen) {
YAHOO.util.Event.removeListener(this._theIMG, 'load');
YAHOO.util.Event.removeListener(this._theIMG, 'abort');
YAHOO.util.Event.removeListener(this._theIMG, 'error');
}
this._uploadImageStep = 0;
this._convertStep = 0;
this._imageDialog.destroy();
this._imageDialog = null;
if (this._profileDialog === null) {
this._inEditMode = false;
}
};
" + FIRSTCLASS.locale.editProfile.next;
showhideTD.innerHTML = html;
}
else
{
YAHOO.util.Dom.setStyle(basicStuff,"display","none");
YAHOO.util.Dom.setStyle(extraStuff,"display","");
html = "
" + FIRSTCLASS.locale.editProfile.prev;
showhideTD.innerHTML = html;
}
};
FIRSTCLASS.apps.Profile.prototype.editProfileData = function ()
{
this._bodyDivElement = document.createElement('div');
var msgCfg = {
callback: this,
element: this._bodyDivElement,
objType: FIRSTCLASS.objTypes.formdoc,
formID: 20502,
formElId: "fcProfileOverviewForm",
bodyType: "",
quoteText: null,
sendTo: null,
params: "Clear=0",
op: FIRSTCLASS.opCodes.FormEdit,
baseURL: (this._MyProfile) ? FIRSTCLASS.session.baseURL + "__Open-Item/SharedDocuments/FCXResume" : this._baseUrl + "FCXResume"
};
this._uploadImageStep = 0;
this._editor = new FIRSTCLASS.util.Message(msgCfg);
};
FIRSTCLASS.apps.Profile.prototype.onLoaded = function(isEditable) {
if (!isEditable) {
alert(FIRSTCLASS.locale.profile.noEdit);
this._inEditMode = false;
}
};
FIRSTCLASS.apps.Profile.prototype.validate = function() {
if (this._uploadImageStep === 0) {
return true;
}
if (this._uploadImageStep == 2) {
this._uploadImageStep = 3;
var uploadName = document.getElementById('insertimage_upload');
if (uploadName !== null) {
if (uploadName.value === "") {
this._uploadImageStep = 2;
alert(FIRSTCLASS.locale.profileImageUpload.selectImage);
} else if (uploadName.value.match('.jpg$|.JPG$|.jpeg$|.JPEG$') === null) {
this._uploadImageStep = 2;
alert(FIRSTCLASS.locale.profileImageUpload.onlyJPG);
} else {
YAHOO.util.Dom.setStyle(document.getElementById('uploader_image'),"display","inline");
document.getElementById("whichStep").innerHTML = FIRSTCLASS.locale.profileImageUpload.step1;
YAHOO.util.Dom.setStyle(document.getElementById('completebar'),"display","block");
YAHOO.util.Dom.setStyle(document.getElementById('whichStep'),"display","");
return true;
}
}
return false;
}
return false;
};
FIRSTCLASS.apps.Profile.prototype.onFail = function(o)
{
if (this._uploadImageStep === 0) { // must be profile
alert(FIRSTCLASS.locale.profile.noRetrieve);
} else {
var alertText;
if (o.statusText) {
alertText = FIRSTCLASS.locale.doSub(FIRSTCLASS.locale.profile.failwitherror,{status:o.statusText});
} else {
alertText = FIRSTCLASS.locale.profile.failnoerror;
}
alert(alertText);
this._cleanupUpload(false);
}
this._inEditMode = false;
};
FIRSTCLASS.apps.Profile.prototype.onCancel = function() {
var profileURL = FIRSTCLASS.util.User.getProfileUrlByCid(FIRSTCLASS.session.user.cid);
if (this._uploadImageStep === 0) { // was editing profile, so close it.
FIRSTCLASS.util.net.asyncRequest('GET',profileURL + 'FCXResume?Close=0',{});
this._profileDialog.destroy();
this._profileDialog = null;
this._inEditMode = false;
} else {
if (this._uploadImageStep == 4) { // was editing pic, so delete temp.
FIRSTCLASS.util.net.asyncRequest('GET', profileURL + 'FCXResume/profile_temp.jpg?Delete=1',null);
}
if (this._imageDialog !== null) {
this._imageDialog.destroy();
this._imageDialog = null;
}
this._uploadImageStep = 0;
if (this._profileDialog === null) {
this._inEditMode = false;
}
}
};
FIRSTCLASS.apps.Profile.prototype.onDisplay = function() {
if (this._uploadImageStep == 1) {
this._uploadImageStep = 2;
this.setupImageDialog();
} else {
this._createProfile = false;
this.setupProfileDialog();
}
};
FIRSTCLASS.apps.Profile.prototype.onSave = function()
{
var that = this;
if (this._uploadImageStep == 3) {
this._uploadImageStep = 4;
this._theIMG = FIRSTCLASS.ui.Dom.getChildByClassName('crop1', this._pictureDivElement);
YAHOO.util.Event.addListener(this._theIMG, 'load', function() { that._resizeUploaded(this); } );
this._theIMG.src = FIRSTCLASS.session.baseURL + "__Open-Item/SharedDocuments/FCXResume/profile_temp.jpg?" + FIRSTCLASS.ui.Dom.getCurrTimestamp();
} else {
// this._updateProfileCompleteness(); NO LONGER SHOW PROFILE BARGRAPH
this._profileDialog.destroy();
this._profileDialog = null;
this._inEditMode = false;
this._createProfile = false;
if (this._blankProfile) {
this._getProfileOverview();
} else {
this._updateProfileOverview();
}
this._uploadImageStep = 0;
}
};
FIRSTCLASS.apps.Profile.prototype._updateProfileCompleteness = function()
{
//var tempComplete = {FIRSTCLASS.locale.profileCompleteness.photo:0,FIRSTCLASS.locale.profileCompleteness.bio:0,FIRSTCLASS.locale.profileCompleteness.expertise:0,FIRSTCLASS.locale.profileCompleteness.phone:0,FIRSTCLASS.locale.profileCompleteness.manager:0,FIRSTCLASS.locale.profileCompleteness.im:0,FIRSTCLASS.locale.profileCompleteness.department:0,FIRSTCLASS.locale,profileCompleteness.education:0};
var tempComplete = {"photo":0,"bio":0,"expertise":0,"phone":0,"manager":0,"IM":0,"department":0,"education":0};
var tempCompleteNames = [FIRSTCLASS.locale.profileCompleteness.photo,FIRSTCLASS.locale.profileCompleteness.bio,FIRSTCLASS.locale.profileCompleteness.expertise,FIRSTCLASS.locale.profileCompleteness.phone,FIRSTCLASS.locale.profileCompleteness.manager,FIRSTCLASS.locale.profileCompleteness.im,FIRSTCLASS.locale.profileCompleteness.department,FIRSTCLASS.locale.profileCompleteness.education];
var fieldIDs = ["0","3019","3012","3010","3002","3017","3024","3013"];
var tempInput;
var index = FIRSTCLASS.ui.Dom.getChildByIdName("2017", this._bodyDivElement).value;
if (index > 0) {
tempComplete.IMType = 1;
} else {
tempComplete.IMType = index;
}
for (index=1; index < 8; ++index) {
tempInput = FIRSTCLASS.ui.Dom.getChildByIdName(fieldIDs[index], this._bodyDivElement);
if ((tempInput!==null) && (tempInput.value.length > 0)) {
tempComplete[tempCompleteNames[index]] = 1;
}
}
FIRSTCLASS.session.desktop.updateProfileInfo(tempComplete);
};
FIRSTCLASS.apps.Profile.prototype._resizeUploaded = function(theIMG)
{
var cropperTable = document.getElementById('profile_imagecropper');
YAHOO.util.Dom.setStyle(cropperTable,"display","inline");
this.realImageWidth = theIMG.width;
this.realImageHeight = theIMG.height;
YAHOO.util.Dom.setStyle(cropperTable,"display","none");
var that = this;
var maxSize = 550.0;
var screenSize;
var resizeParam;
if (typeof screen != "undefined") {
screenSize = (screen.width > screen.height) ? screen.height : screen.width;
if ((screenSize * 0.65) < maxSize) {
maxSize = parseInt(maxSize * 0.65,10);
}
}
if ((this.realImageWidth > maxSize) || (this.realImageHeight > maxSize)) {
if (this.realImageWidth > this.realImageHeight) {
this._percentResize = this.realImageWidth / maxSize;
resizeParam = "Width=" + maxSize + "&Height=" + parseInt(this.realImageHeight/this._percentResize,10);
} else {
this._percentResize = this.realImageHeight / maxSize;
resizeParam = "Width=" + parseInt(this.realImageWidth/this._percentResize,10) + "&Height=" + maxSize;
}
} else {
this._percentResize = 1;
resizeParam = "Height=" + this.realImageHeight;
}
YAHOO.util.Event.removeListener(this._theIMG,'load');
YAHOO.util.Event.addListener(this._theIMG, 'load', function() {
that._setupCropper(that._theIMG);
var button = document.getElementById('fcDocFormSave');
YAHOO.util.Dom.setStyle(button,"display","none");
button = document.getElementById('profile_cropbutton');
YAHOO.util.Dom.setStyle(button,"display","inline");
});
this._theIMG.src = this._theIMG.src + "&" + resizeParam;
};
FIRSTCLASS.apps.Profile.prototype._setupCropper = function(theIMG)
{
var that = this;
var initX, initY;
var cropperTable = document.getElementById('profile_imageupload');
document.getElementById("whichStep").innerHTML = FIRSTCLASS.locale.profileImageUpload.step2;
YAHOO.util.Dom.setStyle(document.getElementById("percentage"),"width","40%");
YAHOO.util.Dom.setStyle(cropperTable,"display","none");
cropperTable = document.getElementById('profile_imagecropper');
YAHOO.util.Dom.setStyle(cropperTable,"display","inline");
var cropWidth = theIMG.width;
var cropHeight = theIMG.height;
YAHOO.util.Dom.setStyle(this._imageDialog.element.firstChild,'width',(theIMG.width < 380 ? 400 : theIMG.width + 20) +'px');
if ((cropWidth / cropHeight) > 0.75) {
cropWidth = cropHeight * 0.75;
initX = parseInt((theIMG.width-cropWidth)/2,10);
initY = 0;
} else {
cropHeight = (cropWidth * 4)/3;
initX = 0;
initY = parseInt((theIMG.height-cropHeight)/2,10);
}
this._cropper = new YAHOO.widget.ImageCropper(
'crop1',
{
initialXY: [initX,initY],
initHeight: cropHeight,
initWidth: cropWidth,
keyTick: 5,
shiftKeyTick: 50,
ratio:true
}
);
var cropButton = document.getElementById('profile_cropbutton');
YAHOO.util.Event.addListener(cropButton, 'click', function() { that._saveProfileImages(); });
this._imageDialog.center();
};
FIRSTCLASS.apps.Profile.prototype._saveProfileImages = function()
{
var that = this;
var theURL;
var url135x180;
var origCroppedH;
var coords = this._cropper.getCropCoords();
var clipWithTime;
document.getElementById("whichStep").innerHTML = FIRSTCLASS.locale.profileImageUpload.step3;
YAHOO.util.Event.removeListener(this._theIMG, 'load');
this._theIMG = document.getElementById('resizedImage');
document.getElementById('fcProfilePicture').src = FIRSTCLASS.session.ui.fcbase.absolute + "/images/uploading_ar32x32.gif";
coords.left = parseInt(coords.left * this._percentResize,10);
coords.top = parseInt(coords.top * this._percentResize,10);
coords.width = parseInt(coords.width * this._percentResize,10);
coords.width = coords.width - (coords.width % 3);
origCroppedH = coords.height;
coords.height = parseInt(coords.width * 4,10) / 3;
// ensure that cropper didn't get it "maintain ratio" screwed up
if (coords.height > this.realImageHeight) {
coords.height = parseInt(origCroppedH * this._percentResize,10);
coords.height = coords.height - (coords.height % 4);
coords.width = parseInt(coords.height * 3,10) / 4;
}
var finalWidth = (coords.width > 135) ? 135 : coords.width;
var finalHeight = (coords.height > 180) ? 180 : coords.height;
var sharedFolder = FIRSTCLASS.util.User.getProfileUrlByCid(FIRSTCLASS.session.user.cid);
var httpPart = sharedFolder.indexOf("/Login");
if (httpPart > -1) {
sharedFolder = sharedFolder.substring(httpPart,sharedFolder.length);
}
var handleSuccess = function(o) {
if (that._convertStep == 1) {
document.getElementById("whichStep").innerHTML = FIRSTCLASS.locale.profileImageUpload.step4;
YAHOO.util.Dom.setStyle(document.getElementById("percentage"),"width","60%");
that._convertStep = 2;
theURL = clipWithTime + "&WidthAA=50&HeightAA=67&SaveDest=" + sharedFolder + "FCXResume/profile_50x67.jpg";
that._theIMG.src = theURL;
} else if (that._convertStep == 2) {
document.getElementById("whichStep").innerHTML = FIRSTCLASS.locale.profileImageUpload.step5;
YAHOO.util.Dom.setStyle(document.getElementById("percentage"),"width","80%");
that._convertStep = 3;
theURL = clipWithTime + "&WidthAA=20&HeightAA=27&SaveDest=" + sharedFolder + "FCXResume/profile_20x27.jpg";
that._theIMG.src = theURL;
} else if (that._convertStep == 3) {
YAHOO.util.Dom.setStyle(document.getElementById("percentage"),"width","90%");
that._convertStep = 4;
theURL = clipWithTime + "&SaveDest=" + sharedFolder + "FCXResume/profile_original.jpg";
that._theIMG.src = theURL;
} else if (that._convertStep == 4) {
YAHOO.util.Dom.setStyle(document.getElementById("percentage"),"width","100%");
that._convertStep = 5;
FIRSTCLASS.util.User.updateLatestImageTimestamp();
document.getElementById("fcProfilePicture").src = url135x180;
if (that._profileDialog) {
document.getElementById('editProfilePic').src = url135x180;
}
that._theIMG.src = FIRSTCLASS.util.User.getSmallProfPicUrlByCid(that._config.params.cid);
} else if (that._convertStep == 5) {
// FIRSTCLASS.util.net.asyncRequest('GET',sharedFolder + "FCXResume/profile_temp.jpg?Delete=1", null);
that._cleanupUpload(true);
}
};
var handleFailure = function(o){
document.getElementById('fcProfilePicture').src = "";
if (typeof o.status != 'undefined') {
alert(FIRSTCLASS.locale.doSub(FIRSTCLASS.locale.profileImageUpload.failwitherror,{status:o.status}));
} else {
alert(FIRSTCLASS.locale.profileImageUpload.failnoerror);
}
that._cleanupUpload(true);
};
this._callback = {
success:handleSuccess,
failure: handleFailure
};
this._convertStep = 1;
YAHOO.util.Event.addListener(this._theIMG, 'load', handleSuccess);
YAHOO.util.Event.addListener(this._theIMG, 'abort', handleFailure);
YAHOO.util.Event.addListener(this._theIMG, 'error', handleFailure);
clipWithTime = sharedFolder + "FCXResume/profile_temp.jpg?" + FIRSTCLASS.ui.Dom.getCurrTimestamp() + "&Clip=" + coords.left + "_" + coords.top + "_" + (coords.left + coords.width) + "_" + (coords.top + coords.height);
url135x180 = clipWithTime + "&WidthAA=" + finalWidth + "&HeightAA=" + finalHeight;
theURL = url135x180 + "&SaveDest=" + sharedFolder + "FCXResume/profile_135x180.jpg";
this._theIMG.src = theURL;
};
FIRSTCLASS.apps.Profile.prototype._cleanupUpload = function(removeListen)
{
if (removeListen) {
YAHOO.util.Event.removeListener(this._theIMG, 'load');
YAHOO.util.Event.removeListener(this._theIMG, 'abort');
YAHOO.util.Event.removeListener(this._theIMG, 'error');
}
this._uploadImageStep = 0;
this._convertStep = 0;
this._imageDialog.destroy();
this._imageDialog = null;
if (this._profileDialog === null) {
this._inEditMode = false;
}
};