/** * 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(""); tmp.push(""); tmp.push("
" + this._topLevelSearch + "
" + this._topLevelMenu.innerHTML + "
"); 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("" + whosProfile + ""); if (this._MyProfile) { tmp.push("Create your first blog entry here "); 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 = ""; var newProfileData = FIRSTCLASS.ui.Dom.getChildByIdName('fcProfileUserData',newDiv); OldProfileData.innerHTML = newProfileData.innerHTML; that._setupProfileLinks(that._resumeDomElement); var 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; } */ } }; 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"; FIRSTCLASS.util.net.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,10); 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(""); if (isOnline=="1") { tmp.push(""); } else { tmp.push(""); if (!isNaN(statTime) && (statTime !== 0)) { tmp.push(""); } tmp.push("
"); } tmp.push("" + FIRSTCLASS.util.expandHashTags(statMsg.parseURLS()) + "
(" + FIRSTCLASS.util.Date.getFriendlyDateTimeString(FIRSTCLASS.lang.fcTimeToDate(statTime)) + ")
"); statusDom.innerHTML = tmp.join(""); } else { var blankText = FIRSTCLASS.locale.profile.clickToSet; if (statMsg === "") { statMsg = blankText; } tmp.push(""); tmp.push("
"); if ((statTime!==0) && !isNaN(statTime)) { tmp.push("
(" + FIRSTCLASS.util.Date.getFriendlyDateTimeString(FIRSTCLASS.lang.fcTimeToDate(statTime)) + ")"); } tmp.push("
"); statusDom.innerHTML = tmp.join(""); var curstatus = FIRSTCLASS.ui.Dom.getChildByIdName('fcProfileBlogStatus', statusDom); if (curstatus.offsetHeight < curstatus.scrollHeight) { YAHOO.util.Dom.setStyle(curstatus,"height",curstatus.scrollHeight + "px"); } var listener = FIRSTCLASS.session.desktop; if (listener && listener.saveProfileStatus) { YAHOO.util.Event.addListener(curstatus, "keyup", function(evt) { if (evt.keyCode == 27) { curstatus.value = FIRSTCLASS.util.BuddyList._message; curstatus.blur(); } else if (evt.keyCode == 13) { curstatus.blur(); } YAHOO.util.Event.stopPropagation(evt); }); YAHOO.util.Event.addListener(curstatus, "blur", function(evt) { curstatus.value = curstatus.value.replace(/\r\n$|\r$|\n$/g, ""); curstatus.value = curstatus.value.replace(/\r\n|\r|\n/g, " "); if (curstatus.value.length <= 0) { curstatus.value = blankText; } else if (curstatus.value != FIRSTCLASS.util.BuddyList._message) { listener.saveProfileStatus(curstatus.value); } YAHOO.util.Dom.removeClass(curstatus, "focussed"); if (curstatus.offsetHeight < curstatus.scrollHeight) { YAHOO.util.Dom.setStyle(curstatus,"height",curstatus.scrollHeight + "px"); } }); YAHOO.util.Event.addListener(curstatus, "focus", function(evt) { if (curstatus.value == blankText) { curstatus.value = ""; } else { curstatus.select(); } YAHOO.util.Dom.addClass(curstatus, "focussed"); }); } } } }; FIRSTCLASS.apps.Profile.prototype._getGroupHierarchy = function () { var that = this; var index=0; var aRow; var currPGNum=0; var needMore = false; var myID=0; var firstResponseText = ""; var handleFailure = function(o){ if(o.responseText != 'undefined') { that._createProfile = that._createProfile; } }; var handleSuccess3 = function(o) { if(o.responseText !== 'undefined') { that.addChildren(firstResponseText,currPGNum,index,o.responseText); } }; var callback3 = { success:handleSuccess3, failure: handleFailure }; var handleSuccess2 = function(o) { if(o.responseText !== 'undefined') { if (needMore) { firstResponseText = o.responseText; var theURL = FIRSTCLASS.session.baseURL + "__Directory/__Lookup?Srch=&Templates=JS&Groups=-7&Table=0_0&ClientID=" + myID; FIRSTCLASS.util.net.asyncRequest('GET', theURL, callback3); } else { that.addChildren(o.responseText,currPGNum,index,null); } } }; var callback2 = { success:handleSuccess2, failure: handleFailure }; var handleSuccess = function(o) { if(o.responseText !== 'undefined') { var IDforChildren; var obj = FIRSTCLASS.lang.JSON.parse(o.responseText); if (obj.records.length === 0) { return; } else { YAHOO.util.Dom.setStyle(document.getElementById('orgTitle'),"display",""); } if (obj.records.length == 1) { IDforChildren = obj.records[0].uid; } else { myID = obj.records[obj.records.length-1].uid; IDforChildren = obj.records[obj.records.length-2].uid; needMore = true; } var numRecords = obj.records.length-1; currPGNum = obj.records[numRecords].rankorpgnum; aRow = obj.records[0]; if (obj.records.length==1) { that.theHTML = "
" + aRow.orgname + "
"; } else { that.theHTML = "
" + aRow.orgname + "
"; } for (index=1; index < numRecords; ++index) { aRow = obj.records[index]; that.theHTML = that.theHTML + "
" + aRow.orgname + "
"; } var theURL = FIRSTCLASS.session.baseURL + "__Directory/__Lookup?Srch=&Templates=JS&Groups=-7&Table=0_0&ClientID=" + IDforChildren; FIRSTCLASS.util.net.asyncRequest('GET', theURL, callback2); } }; var callback = { success:handleSuccess, failure: handleFailure }; var theURL = FIRSTCLASS.session.baseURL + "__Directory/__Lookup?Srch=&Templates=JS&Groups=-5&Table=0_0&ClientID=" + this._config.params.cid.substr(3); FIRSTCLASS.util.net.asyncRequest('GET', theURL, callback); }; FIRSTCLASS.apps.Profile.prototype.addChildren = function (oResponse,currPGNum,index,theChildren,indentIt) { var that=this; var hierarchy = document.getElementById('org_hierarchy'); var currIndent = (index+1)*8; var theColour; var theImage = "s"; var extraImage = indentIt ? "" : ""; var obj = FIRSTCLASS.lang.JSON.parse(oResponse); var index2=0; var aRow; if (indentIt) { index += 8; } if (obj.records.length == 1) { aRow = obj.records[0]; that.theHTML = that.theHTML + "
" + extraImage + "" + aRow.orgname + "
"; } else if (obj.records.length !== 0) { obj.records.sort(function(a,b) { var c = a; var d = b; return c.orgname > d.orgname ? 1 : (c.orgname < d.orgname ? -1 : 0); }); aRow = obj.records[0]; // currIndent += 8; if (currPGNum == aRow.rankorpgnum) { that.theHTML = that.theHTML + "
" + extraImage + "" + aRow.orgname + "
"; this.addChildren(theChildren,currPGNum,index,null,obj.records.length>1); } else { that.theHTML = that.theHTML + "
" + extraImage + "" + aRow.orgname + "
"; } for (index2=1; index2 < obj.records.length; ++index2) { aRow = obj.records[index2]; if (currPGNum == aRow.rankorpgnum) { theColour = "00c0c0"; } else { theColour = "ffffff"; } if (index2 == obj.records.length-1) { theImage = "sb"; } that.theHTML = that.theHTML + "
" + extraImage + "" + aRow.orgname + "
"; if ((currPGNum == aRow.rankorpgnum) && theChildren) { if (index2!=obj.records.length-1) { this.addChildren(theChildren,currPGNum,index,null,true); } else { this.addChildren(theChildren,currPGNum,index+1,null,false); } } } } hierarchy.innerHTML = that.theHTML; }; FIRSTCLASS.apps.Profile.prototype._getProfileOverview = function (configure) { var that = this; var handleSuccess = function(o) { if(o.responseText !== 'undefined') { if (o.responseText.indexOf("ERR404") >= 0) { this.failure(o); return; } if (configure) { that.configure(); } that._blankProfile = false; that._resumeDomElement.innerHTML = o.responseText; var langDiv; var langExtension = YAHOO.util.Cookie.get('fcislang'); if ((langExtension===null) || (langExtension == 'en')) { langDiv = document.getElementById('fr_language'); } else { langDiv = document.getElementById('en_language'); } FIRSTCLASS.ui.Dom.setInnerHTML(langDiv,""); that.updateStatusInfo(); that._setupProfileLinks(that._resumeDomElement); var domElem = document.getElementById("fcProfileResume"); that.createSearchLinks(domElem); that._setFollowers(); if ((typeof that._config.params != "undefined") && (typeof that._config.params.editProfile != "undefined")) { if (typeof that._config.params.editProfile == 'string') { that.ensureProfile("editProfilePicture"); } else if (that._config.params.editProfile !== 0) { that.ensureProfile("editProfileData"); } } } }; var handleFailure = function(o){ if (configure) { that.configure(); } if(o.responseText !== 'undefined'){ that._createProfile = true; that._blankProfile = true; that._setupBlankProfile(); if (that._config.params !== null) { if ((typeof that._config.params != "undefined") && (typeof that._config.params.editProfile != "undefined")) { if (typeof that._config.params.editProfile == 'string') { that.ensureProfile("editProfilePicture"); } else if (that._config.params.editProfile !== 0) { that.ensureProfile("editProfileData"); } } } } if (that._config.onLoaded) { that._config.onLoaded(); } }; var callback = { success:handleSuccess, failure: handleFailure }; var theURL = (this._MyProfile) ? FIRSTCLASS.session.baseURL + "__Open-Item/SharedDocuments/FCXResume" : that._config.baseUrl + "FCXResume"; if (typeof that._config.params.name != 'undefined') FIRSTCLASS.util.net.asyncRequest('GET', theURL+"?Close=0&username="+that._config.params.name, callback); else FIRSTCLASS.util.net.asyncRequest('GET', theURL+"?Close=0", callback); }; FIRSTCLASS.apps.Profile.prototype._setupBlankProfile = function (forbidden) { var tmp = []; if (this._MyProfile) { tmp.push(""); tmp.push("
" + FIRSTCLASS.locale.profile.ownmissing + ""); tmp.push("
" + FIRSTCLASS.locale.profile.changePicture + "
"); tmp.push("
" + FIRSTCLASS.locale.profile.editProfile + "
"); tmp.push("
"); tmp.push(""); tmp.push("
" + FIRSTCLASS.locale.profile.positioninorg + "
"); FIRSTCLASS.ui.Dom.setInnerHTML(this._resumeDomElement,tmp.join("")); this._setupProfileLinks(this._resumeDomElement); } else if (forbidden) { tmp.push(""); tmp.push("
" + FIRSTCLASS.locale.profile.othermissing + "
"); tmp.push(""); tmp.push("
" + FIRSTCLASS.locale.profile.positioninorg + "
"); FIRSTCLASS.ui.Dom.setInnerHTML(this._resumeDomElement, tmp.join("")); } else { tmp.push(""); tmp.push("
" + FIRSTCLASS.locale.profile.othermissing + "
"); tmp.push(""); tmp.push("
" + FIRSTCLASS.locale.profile.positioninorg + "
"); FIRSTCLASS.ui.Dom.setInnerHTML(this._resumeDomElement,tmp.join("")); FIRSTCLASS.util.User.setLargeProfPicUrlByCid(document.getElementById("fcProfilePicture"),this._config.params.cid,false,false,false); this.setupSubscribing(); } }; FIRSTCLASS.apps.Profile.prototype._setupProfileLinks = function (editProflieDiv) { var that = this; FIRSTCLASS.util.User.setLargeProfPicUrlByCid(document.getElementById("fcProfilePicture"),this._config.params.cid,false,false,false); var editOverview = document.getElementById('fcProfileEditOverviewBtn'); var editPicture = document.getElementById('fcProfileEditPictureBtn'); if (this._MyProfile) { YAHOO.util.Dom.addClass(document.getElementById('fcProfileNewBlogBtn'),'fcHeaderPlusButton'); // New Blog Entry"; if (editOverview !== null) { this._setupForGlow('fcProfileEditOverview',true); YAHOO.util.Event.addListener(editOverview, 'click', function() { that.ensureProfile("editProfileData"); }); } if (editPicture !== null) { this._setupForGlow('fcProfileEditPicture',true); YAHOO.util.Event.addListener(editPicture, 'click', function() { that.ensureProfile("editProfilePicture"); }); } } else { var editButtons = FIRSTCLASS.ui.Dom.getChildByClassName('fcProfileEditButtons',this._resumeDomElement); if (editButtons !== null) { FIRSTCLASS.ui.Dom.setInnerHTML(editButtons,""); } this.setupSubscribing(); } }; FIRSTCLASS.apps.Profile.prototype._setFollowers = function () { var that = this; this._memberlistds = new FIRSTCLASS.util.DataSource( { symbioticDataSource: {dataSource:that._dataSource, key:"subscribers"}, itemrequest: false, compareRows:function(row1, row2) { return row1.online == row2.online; }, isSameRow: function(row1, row2) { return row1.uid == row2.uid; } } ); if (this._config.params.uid != 30732) { YAHOO.util.Dom.setStyle(document.getElementById('profileFollowers'),'display',''); } var tempFollow = FIRSTCLASS.locale.doSub(FIRSTCLASS.locale.profile.followers,{whosProfile:document.getElementById('fcProfileUserName').innerHTML.toUpperCase()}); FIRSTCLASS.locale.setElementString(tempFollow,document.getElementById('followersTitle')); this._memberlist = document.getElementById('memberListDiv'); var memberlistcfg = { domElement: this._memberlist, dataSource: this._memberlistds, threading: { format: FIRSTCLASS.layout.ThreadHandler.types.NONE, sortfunc: function(row1, row2) { if (row1.name > row2.name) { return 1; } else if (row1.name == row2.name) { return 0; } else { return -1; } } }, compareRows:function(row1,row2) { return row1.online == row2.online && row1.what == row2.what && row1.lastin == row2.lastin; }, keepRowsSorted: true, rowHandler: new FIRSTCLASS.layout.UserListHandler(that._memberlistds,false,false) }; this._memberlistlv = new FIRSTCLASS.layout.ListView(memberlistcfg); }; FIRSTCLASS.apps.Profile.prototype._setupForGlow = function (btnElementID,darkBkgrnd) { var btnElement = document.getElementById(btnElementID); var hoverBtn = darkBkgrnd ? "dark" : "white"; YAHOO.util.Event.purgeElement(btnElement, true); YAHOO.util.Dom.setStyle(btnElement,'cursor','pointer'); YAHOO.util.Event.addListener(btnElement,"mouseover", function() { this.firstChild.firstChild.src = FIRSTCLASS.session.ui.fcbase.absolute + '/images/ButtonON' + hoverBtn + '_left.png'; YAHOO.util.Dom.setStyle(this.firstChild.nextSibling,'background-image','url(' + FIRSTCLASS.session.ui.fcbase.absolute + '/images/ButtonON' + hoverBtn + '_mid.png)'); this.lastChild.firstChild.src = FIRSTCLASS.session.ui.fcbase.absolute + '/images/ButtonON' + hoverBtn + '_right.png'; }); YAHOO.util.Event.addListener(btnElement,"mouseout", function() { this.firstChild.firstChild.src = FIRSTCLASS.session.ui.fcbase.absolute + '/images/ButtonOUTLINE_left.png'; YAHOO.util.Dom.setStyle(this.firstChild.nextSibling,'background-image',''); this.lastChild.firstChild.src = FIRSTCLASS.session.ui.fcbase.absolute + '/images/ButtonOUTLINE_right.png'; }); }; FIRSTCLASS.apps.Profile.prototype.flashButton = function (btnElement) { var that = this; if (this._shine & 1) { btnElement.firstChild.firstChild.src = FIRSTCLASS.session.ui.fcbase.absolute + '/images/ButtonOUTLINE_left.png'; YAHOO.util.Dom.setStyle(btnElement.firstChild.nextSibling,'background-image',''); btnElement.lastChild.firstChild.src = FIRSTCLASS.session.ui.fcbase.absolute + '/images/ButtonOUTLINE_right.png'; } else { btnElement.firstChild.firstChild.src = FIRSTCLASS.session.ui.fcbase.absolute + '/images/ButtonONdark_left.png'; YAHOO.util.Dom.setStyle(btnElement.firstChild.nextSibling,'background-image','url(' + FIRSTCLASS.session.ui.fcbase.absolute + '/images/ButtonONdark_mid.png)'); btnElement.lastChild.firstChild.src = FIRSTCLASS.session.ui.fcbase.absolute + '/images/ButtonONdark_right.png'; } if (this._shine < 3) { ++this._shine; setTimeout(function() { that.flashButton(btnElement); }, 750); } }; FIRSTCLASS.apps.Profile.prototype.setSubscribeBtn = function (subscribeTD,btnElement,isMyBuddy,isFirstTime) { var that = this; if (isMyBuddy) { FIRSTCLASS.ui.Dom.setInnerHTML(btnElement,isFirstTime?FIRSTCLASS.locale.profile.stopFollow : FIRSTCLASS.locale.profile.following); YAHOO.util.Event.removeListener(subscribeTD,'click'); YAHOO.util.Dom.setStyle(subscribeTD,'cursor','default'); YAHOO.util.Event.removeListener(subscribeTD,"mouseover"); } else { FIRSTCLASS.ui.Dom.setInnerHTML(btnElement,FIRSTCLASS.locale.profile.follow); } if (subscribeTD !== null) { that._shine = 0; setTimeout(function() { that.flashButton(subscribeTD); }, 750); } }; FIRSTCLASS.apps.Profile.prototype.setupSubscribing = function () { var that = this; var subscribe = FIRSTCLASS.ui.Dom.getChildByClassName('fcProfileSubscribe',this._domElement); if (subscribe !== null) { var btnTextElem = FIRSTCLASS.ui.Dom.getChildByClassName('fcProfileEditBtns',subscribe); this._setupForGlow(subscribe,true); that.setSubscribeBtn(null,btnTextElem,FIRSTCLASS.util.BuddyList.isBuddy(this._config.params.uid),true); YAHOO.util.Event.addListener(subscribe, 'click', function() { var handleSuccess = function(o) { FIRSTCLASS.util.BuddyList._dataSource.activate(); setTimeout(function() { FIRSTCLASS.util.BuddyList._dataSource.deactivate(); }, 10000); that.setSubscribeBtn(subscribe,btnTextElem,true,false); }; var handleFailure = function(o) { if (btnTextElem !== null) { FIRSTCLASS.ui.Dom.setInnerHTML(btnTextElem,FIRSTCLASS.locale.profile.failed); } }; var callback = { success:handleSuccess, failure: handleFailure }; if (FIRSTCLASS.util.BuddyList.isBuddy(that._config.params.uid)) { FIRSTCLASS.util.BuddyList.deleteBuddy(that._config.params.uid); that.setSubscribeBtn(subscribe,btnTextElem,false,false); } else { FIRSTCLASS.util.BuddyList.addBuddy(that._config.params.name,that._config.params.uid,callback); } }); } } ; /** * Public method definitions */ FIRSTCLASS.apps.Profile.prototype.baseUrl = function () { return this._config.baseUrl; }; FIRSTCLASS.apps.Profile.prototype.resizeEvent = function(evt) { // var theHeightTD = document.getElementById('fcProfileHeight'); // YAHOO.util.Dom.setStyle(theHeightTD,'height',YAHOO.util.Dom.getDocumentHeight()-20 + 'px'); }; FIRSTCLASS.apps.Profile.prototype.activate = function() { FIRSTCLASS.ui.skin.clear(); FIRSTCLASS.ui.leftSideBar.hide(); FIRSTCLASS.ui.rightSideBar.hide(); FIRSTCLASS.ui.navBar.hide(); FIRSTCLASS.ui.navBar.setProfileUnread(0); YAHOO.util.Dom.setStyle(FIRSTCLASS.fcContentElement,'padding-left','0px'); YAHOO.util.Dom.setStyle(document.getElementById("fcNavBarPicture"),"display","none"); YAHOO.util.Dom.setStyle('fcProfileStatus','display','none'); FIRSTCLASS.session.setActiveObject(this._config.baseUrl); FIRSTCLASS.session.setActiveApplication(this, "profile"); this.resizeEvent(); FIRSTCLASS.ui.Dom.replaceContentsWithElement(FIRSTCLASS.fcContentElement,this._domElement); if (this._dataSource !== null) { this._dataSource.activate(); } if (this._memberlistlv) { this._memberlistlv.activate(); this._memberlistds.activate(); } if (YAHOO.env.ua.ie < 8) { document.body.setAttribute('scroll','auto'); } if (this._config.params.showoncomplete) { FIRSTCLASS.util.revealContents(); } }; FIRSTCLASS.apps.Profile.prototype.deactivate = function() { FIRSTCLASS.ui.leftSideBar.show(); FIRSTCLASS.ui.rightSideBar.show(); FIRSTCLASS.ui.navBar.clearContentPane(); FIRSTCLASS.ui.navBar.show(); YAHOO.util.Dom.setStyle(document.getElementById("fcNavBarPicture"),"display","inline"); YAHOO.util.Dom.setStyle(FIRSTCLASS.fcContentElement,'padding-left',''); // do some stuff to go to sleep this._dataSource.deactivate(); if (this._memberlistlv) { this._memberlistlv.deactivate(); this._memberlistds.deactivate(); } FIRSTCLASS.ui.MiniProfile.hideBoxNow(); if (this._profileDialog !== null) { this._profileDialog.destroy(); this._profileDialog = null; } FIRSTCLASS.ui.MiniProfile.hideBoxNow(); }; FIRSTCLASS.apps.Profile.prototype.createSearchLinks = function(theElement) { var eachLink; var theURL; var i,j; var searchLinks = YAHOO.util.Dom.getElementsByClassName("fcProfileSearchLinkNoPad","td",theElement); for (eachLink = 0; eachLink < 2; eachLink++) { for (i = 0; i < searchLinks.length; i++) { var theLinkDiv = searchLinks[i]; var AllLinks = theLinkDiv.innerHTML.split(","); if (AllLinks.length > 0) { var theHREF = ""; var FinalLinks = ""; for(j = 0; j < AllLinks.length; j++){ AllLinks[j] = AllLinks[j].replace(/^\s+/g, '').replace(/\s+$/g, ''); theHREF = AllLinks[j].replace(/%20/g," ").replace(/&/g,"&"); theURL = theHREF.parseURLS(); if (theURL.indexOf("") > 0) { FinalLinks = FinalLinks + theURL; } else { FinalLinks = FinalLinks + "" + AllLinks[j] + ""; } if (j != AllLinks.length-1) { FinalLinks = FinalLinks + ", "; } } theLinkDiv.innerHTML = FinalLinks; } } searchLinks = YAHOO.util.Dom.getElementsByClassName("fcProfileSearchLinkPad","div",theElement); } searchLinks = FIRSTCLASS.ui.Dom.getChildByIdName("profileBio",theElement); if (searchLinks) { searchLinks.innerHTML = searchLinks.innerHTML.parseURLS(); } this.updateHREF('linkedin','linkedin.com/in/',false); this.updateHREF('twitter','twitter.com/',true); this.updateHREF('flickr','flickr.com/photos/',false); this.updateHREF('delicious','delicious.com/',true); this.updateHREF('publicblog'); this.updateHREF('publicwebsite'); }; FIRSTCLASS.apps.Profile.prototype.updateHREF = function(website,urlpart,skipWWW) { var theHREF; var sessPath; var theAnchor = document.getElementById(website); if (theAnchor) { theHREF = theAnchor.href; sessPath = FIRSTCLASS.lang.extractSessionPath(theHREF); if (sessPath != "Desktop") { if (sessPath.indexOf('www.') !== 0) { if ((typeof urlpart != 'undefined') && (sessPath.indexOf(urlpart) < 0)) { sessPath = urlpart + sessPath; } if (skipWWW || (sessPath.indexOf('www.') === 0)) { sessPath = 'http://' + sessPath; } else { sessPath = 'http://www.' + sessPath; } } else { sessPath = 'http://' + sessPath; } theAnchor.href = sessPath; } } }; FIRSTCLASS.apps.Profile.prototype.createAddress = function() { return document.getElementById("mainaddress").innerHTML + " " + document.getElementById("citystuff").innerHTML; }; FIRSTCLASS.apps.Profile.prototype.loadApplication = function(tabName, activate) { var that = this; var j=-1; if (typeof activate == "undefined") { activate = true; } for(var i = 0; i < this._subApps.length; i++) { if (this._subApps[i].label == tabName) { j = i; break; } } if (j >= 0) { FIRSTCLASS._loader.onSuccess = function(o) { var app = that._subApps[j]; if (!app.instance) { var domElem = document.getElementById("fcProfileBlogContent"); /*domElem.style.overflow = "auto";*/ YAHOO.util.Dom.setStyle(domElem,"height","100%"); var config = {domElement: domElem, dataSource: that._dataSource, userCID: that._config.params.cid, singleThreadView: that._singleThreadView,theProfile:that}; switch (tabName) { case "Overview": app.instance = that; // do nothing; break; case "Blog": app.instance = new FIRSTCLASS.apps.Blog(config); break; default: break; } } if (activate && app.instance && app.instance.activate) { app.instance.activate(); } }; FIRSTCLASS._loader.insert(); } }; FIRSTCLASS.apps.Profile.prototype.createOriginalProfile = function (callback) { var that = this; this._createProfile = false; var handleCreateSuccess = function(o) { that[callback](); }; var handleCreateFail = function(o) { alert (FIRSTCLASS.locale.doSub(FIRSTCLASS.locale.profile.cantcreate,{status:o.status})); that._createProfile = true; that._inEditMode = false; }; var createdCB = { success:handleCreateSuccess, failure: handleCreateFail }; var handleHasProfile = function(o) { that[callback](); }; var handleNoProfile = function(o) { FIRSTCLASS.util.net.asyncRequest('GET',FIRSTCLASS.session.baseURL + "__Open-Item/SharedDocuments/" + FIRSTCLASS.opCodes.Create +"?What=FormDoc&Name=FCXResume&Type=20502",createdCB); }; var checkProfileCB = { success:handleHasProfile, failure: handleNoProfile }; FIRSTCLASS.util.net.asyncRequest('HEAD',FIRSTCLASS.util.User.getProfileUrlByCid(FIRSTCLASS.session.user.cid) + 'FCXResume?Close=0',checkProfileCB); }; FIRSTCLASS.apps.Profile.prototype.ensureProfile = function (editWhat) { if (this._inEditMode) { return; } else if (!this.isSafeToNavigate()) { alert(FIRSTCLASS.locale.editProfile.closepost); return; } this._inEditMode = true; if (this._createProfile) { this.createOriginalProfile(editWhat); } else { this[editWhat](); } }; FIRSTCLASS.apps.Profile.prototype.editProfilePicture = function () { var that = this; this._config.params.editProfile = 0; this._pictureDivElement = document.createElement('div'); var msgCfg = { callback: this, element: this._pictureDivElement, objType: FIRSTCLASS.objTypes.odocument, formID: 20001, formElId: "ProfileImage", bodyType: "", quoteText: null, sendTo: null, op: FIRSTCLASS.opCodes.MemForm, upload: true, baseURL: FIRSTCLASS.session.baseURL, overrideForms: "" }; // ensure any left over temp files are deleted first var handleSuccessOrFail = function(o) { that._editor = new FIRSTCLASS.util.Message(msgCfg); }; var callback = { success:handleSuccessOrFail, failure: handleSuccessOrFail }; this._uploadImageStep = 1; FIRSTCLASS.util.net.asyncRequest('GET', FIRSTCLASS.util.User.getProfileUrlByCid(FIRSTCLASS.session.user.cid)+'FCXResume/profile_temp.jpg?Delete=1',callback); }; FIRSTCLASS.apps.Profile.prototype.setupImageDialog = function () { var that = this; if (this._imageDialog !== null) { this._imageDialog.destroy(); } this._imageDialog = new YAHOO.widget.Dialog("imgDialog", { width : "600px", fixedcenter : false, draggable: true, visible : true, constraintoviewport : true, postmethod : "manual", modal:true, shim: (navigator.userAgent.toLowerCase().indexOf("msie") > -1) } ); this._imageDialog.validate = function () { return false; /* we handle it ourself */ }; this._imageDialog.setHeader(FIRSTCLASS.locale.profile.changePicture); this._imageDialog.setBody(this._pictureDivElement); YAHOO.util.Dom.setStyle(this._pictureDivElement,"display","inline"); this._imageDialog.render(document.body); this._imageDialog.center(); this._imageDialog.cancelEvent.subscribe(function(e, a, o) { that.onCancel(); }); }; FIRSTCLASS.apps.Profile.prototype.setupProfileDialog = function () { var that = this; var langDiv; var langExtension = YAHOO.util.Cookie.get('fcislang'); if (this._profileDialog !== null) { this._profileDialog.destroy(); } this._profileDialog = new YAHOO.widget.Dialog("profileDialog", { width : "625px", fixedcenter : false, visible : true, constraintoviewport : true, modal:true, shim: (navigator.userAgent.toLowerCase().indexOf("msie") > -1) } ); if ((langExtension === null) || (langExtension == 'en')) { langDiv = FIRSTCLASS.ui.Dom.getChildByIdName('fr_language_edit',this._bodyDivElement); } else { langDiv = FIRSTCLASS.ui.Dom.getChildByIdName('en_language_edit',this._bodyDivElement); } langDiv.innerHTML = ""; this._profileDialog.validate = function () { return false; /* we handle it ourself */ }; this._profileDialog.setHeader(FIRSTCLASS.locale.profile.editProfile); FIRSTCLASS.util.User.setLargeProfPicUrlByCid(FIRSTCLASS.ui.Dom.getChildByIdName('editProfilePic',this._bodyDivElement),this._config.params.cid,false,false,false); this._profileDialog.setBody(this._bodyDivElement); YAHOO.util.Dom.setStyle(this._bodyDivElement.parentNode,"padding","0px"); YAHOO.util.Dom.setStyle(this._bodyDivElement,"display","inline"); this._profileDialog.render(document.body); document.getElementById('firsttabpos').focus(); var showFull = FIRSTCLASS.ui.Dom.getChildByIdName('fullToggle',this._bodyDivElement); if (this._config.params.editProfile < 0) { this.toggleView(showFull,this._bodyDivElement); document.getElementById((-that._config.params.editProfile)+'').focus(); } else if (this._config.params.editProfile > 0) { document.getElementById(that._config.params.editProfile+'').focus(); } this._config.params.editProfile = 0; this._profileDialog.center(); this._profileDialog.cancelEvent.subscribe(function(e, a, o) { that.onCancel(); }); YAHOO.util.Event.addListener(showFull, 'click', function(evt) { that.toggleView(showFull,that._bodyDivElement); }); var changePic = FIRSTCLASS.ui.Dom.getChildByClassName('fcProfileEditPicture',this._bodyDivElement); this._setupForGlow(changePic,false); YAHOO.util.Event.addListener(changePic, 'click', function() { that.editProfilePicture(); }); }; FIRSTCLASS.apps.Profile.prototype.toggleView = function (showhideTD,dialogElem) { var basicStuff = FIRSTCLASS.ui.Dom.getChildByIdName('profileBasic',dialogElem); var extraStuff = FIRSTCLASS.ui.Dom.getChildByIdName('fcProfileExtra',dialogElem); var basicHidden = (YAHOO.util.Dom.getStyle(basicStuff,"display") == "none"); var html; if (basicHidden) { YAHOO.util.Dom.setStyle(basicStuff,"display",""); YAHOO.util.Dom.setStyle(extraStuff,"display","none"); html = " " + 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; } };