/** * Class Description * @namespace FIRSTCLASS.apps * @module OrgProfile * @requires * @optional * @title Organization Profile */ /** * Constructor definition * @class OrgProfile * @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.orgProfile = 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 = "OrgProfile"; this._listView = null; this._uploadImageStep = 0; this._convertStep = 0; this._initalpadding = 0; this._createProfile = false; this._inEditMode = false; 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; } 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); }; FIRSTCLASS.apps.orgProfile.prototype.configure = function() { FIRSTCLASS.ui.leftSideBar.hide(); FIRSTCLASS.ui.rightSideBar.hide(); this._config.onready(); var that = this; var tmp = []; if ((typeof this._config.params.name == 'undefined') || (this._config.params.name == 'undefined')) { this._config.params.name = ""; } tmp.push("
"); tmp.push ("
"); tmp.push ("
"); tmp.push(""); tmp.push(""); tmp.push(""); tmp.push("
"); tmp.push("
"); tmp.push("
" + this._topLevelMenu.innerHTML + "
"); tmp.push("
  " + FIRSTCLASS.locale.profile.groupDetail + "
"); tmp.push("
" + FIRSTCLASS.locale.profile.userName + "" + FIRSTCLASS.locale.profile.userPos + "" + FIRSTCLASS.locale.profile.phone + "
 
"); 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; FIRSTCLASS.session.addHistoryEntry({ "uri": url, "app": this, activate: function() { that.activate(); } }); }; FIRSTCLASS.apps.orgProfile.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.orgProfile.prototype.isSafeToNavigate = function() { return true; }; FIRSTCLASS.apps.orgProfile.prototype.overrideSafeToNavigate = function() { }; FIRSTCLASS.apps.orgProfile.prototype._updateProfileOverview = function () { var that = this; var handleSuccess = function(o) { if(typeof o.responseText !== 'undefined') { var domElem; 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); that._getGroupHierarchy(); } }; var handleFailure = function(o){ alert(FIRSTCLASS.locale.profile.noRetrieve); }; var callback = { success:handleSuccess, failure: handleFailure }; var theURL = FIRSTCLASS.session.domain + FIRSTCLASS.session.baseURL + "__Open-User/" + this._config.params.cid + "/__Resume/?FormID=97"; FIRSTCLASS.util.net.asyncRequest('GET', theURL+"?Close=0", callback); }; FIRSTCLASS.apps.orgProfile.prototype._getGroupDetails = function (pgNumber) { this.addedGroupDetails = true; var that = this; var handleSuccess = function(o) { if(o.responseText !== 'undefined') { var obj = FIRSTCLASS.lang.JSON.parse(o.responseText); obj.records.sort(function(a,b) { var c = a; var d = b; if (typeof c.rankorpgnum != 'number') { c.rankorpgnum = 0; } if (typeof d.rankorpgnum != 'number') { d.rankorpgnum = 0; } return c.rankorpgnum - d.rankorpgnum; } ); var index; var aRow; var theHTML = ""; // = "
"; var englishDisplay; var frenchDisplay; if (FIRSTCLASS.locale == FIRSTCLASS.languages.fr) { englishDisplay = " style='display:none;'"; frenchDisplay = ""; } else { frenchDisplay = " style='display:none;'"; englishDisplay = ""; } for (index=0; index < obj.records.length; ++index) { aRow = obj.records[index]; theHTML = theHTML + ""; } // theHTML = theHTML + "
NameTitlePhone
 
" + aRow.name + "" + aRow.usertitle + "" + aRow.frenchtitle + "" + aRow.teleorfrname + "
"; var hierarchy = document.getElementById('detailCols'); if (hierarchy !== null) { hierarchy.parentNode.innerHTML = hierarchy.parentNode.innerHTML + theHTML; } } }; var handleFailure = function(o){ if(o.responseText !== 'undefined') { that._createProfile = that._createProfile; } }; var callback = { success:handleSuccess, failure: handleFailure }; var theURL = FIRSTCLASS.session.baseURL + "__Directory/__Lookup?Options=12&Templates=JS&Groups=-8&Table=0_0&ClientID=" + (pgNumber+1); FIRSTCLASS.util.net.asyncRequest('GET', theURL, callback); }; FIRSTCLASS.apps.orgProfile.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); if (!that.addedGroupDetails) that._getGroupDetails(currPGNum); } }; 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; } if (obj.records.length == 1) { IDforChildren = obj.records[0].uid; } else { obj.records.reverse(); 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]; 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 }; that.addedGroupDetails = false; var theURL = FIRSTCLASS.session.baseURL + "__Directory/__Lookup?Srch=&Templates=JS&Groups=-6&Table=0_0&ClientID=" + this._config.params.cid.substr(3); FIRSTCLASS.util.net.asyncRequest('GET', theURL, callback); }; FIRSTCLASS.apps.orgProfile.prototype.addChildren = function (oResponse,currPGNum,index,theChildren,indentIt) { var that=this; var hierarchy = document.getElementById('org_hierarchy'); var currIndent = index*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; if (theChildren === null) { that._getGroupDetails(currPGNum); } }; FIRSTCLASS.apps.orgProfile.prototype.showFrench = function (configure) { YAHOO.util.Dom.setStyle(document.getElementById('englishinfo'),'display','none'); var elem = document.getElementById('frenchinfo'); YAHOO.util.Dom.setStyle(elem,'display',''); document.getElementById('poswithin').innerHTML = "POSITION DANS LA HIÉRARCHIE DE L'ORGANISATION"; document.getElementById('detailHeading').innerHTML = "  Détails de Group"; document.getElementById('detailCols').firstChild.innerHTML = "Nom"; document.getElementById('detailCols').firstChild.nextSibling.innerHTML = "Titre"; document.getElementById('detailCols').firstChild.nextSibling.nextSibling.innerHTML = "Téléphone"; var groupies = document.getElementById('detailCols').nextSibling.nextSibling; while (groupies !== null) { YAHOO.util.Dom.setStyle(groupies.firstChild.nextSibling.firstChild,'display','none'); YAHOO.util.Dom.setStyle(groupies.firstChild.nextSibling.firstChild.nextSibling,'display',''); groupies = groupies.nextSibling; } }; FIRSTCLASS.apps.orgProfile.prototype.showEnglish = function (configure) { YAHOO.util.Dom.setStyle(document.getElementById('englishinfo'),'display',''); var elem = document.getElementById('frenchinfo'); YAHOO.util.Dom.setStyle(elem,'display','none'); document.getElementById('poswithin').innerHTML = "POSITION WITHIN ORGANIZATIONAL HIERARCHY"; document.getElementById('detailHeading').innerHTML = "  Group Details"; document.getElementById('detailCols').firstChild.innerHTML = "Name"; document.getElementById('detailCols').firstChild.nextSibling.innerHTML = "Title"; document.getElementById('detailCols').firstChild.nextSibling.nextSibling.innerHTML = "Phone"; var groupies = document.getElementById('detailCols').nextSibling.nextSibling; while (groupies !== null) { YAHOO.util.Dom.setStyle(groupies.firstChild.nextSibling.firstChild,'display',''); YAHOO.util.Dom.setStyle(groupies.firstChild.nextSibling.firstChild.nextSibling,'display','none'); groupies = groupies.nextSibling; } }; FIRSTCLASS.apps.orgProfile.prototype._getProfileOverview = function (configure) { var that = this; var handleSuccess = function(o) { if (configure) { that.configure(); } if(o.responseText !== 'undefined') { that._resumeDomElement.innerHTML = o.responseText; if (FIRSTCLASS.locale == FIRSTCLASS.languages.fr) { that.showFrench(); } that._getGroupHierarchy(); var domElem = document.getElementById("french"); if (domElem) { YAHOO.util.Event.addListener(domElem, 'click', function() { that.showFrench(); }); } domElem = document.getElementById("english"); if (domElem) { YAHOO.util.Event.addListener(domElem, 'click', function() { that.showEnglish(); }); } var altName = document.getElementById('fcProfileUserName'); if ((altName !== null) && (altName.innerHTML == "")) altName.innerHTML = that._config.params.name; var editOverview = document.getElementById('fcProfileEditOverview'); if (editOverview !== null) { that._setupForGlow(editOverview,true); YAHOO.util.Event.addListener(editOverview, 'click', function() { that.ensureProfile("editProfileData"); }); // YAHOO.util.Event.addListener(editOverview, 'click', function() { that.editProfileData(); }); } } }; var handleFailure = function(o){ alert(FIRSTCLASS.locale.profile.noRetrieve); }; var callback = { success: handleSuccess, failure: handleFailure }; var theURL = FIRSTCLASS.session.domain + FIRSTCLASS.session.baseURL + "__Open-User/" + this._config.params.cid + "/__Resume/?FormID=97"; FIRSTCLASS.util.net.asyncRequest('GET', theURL+"?Close=0", callback); }; FIRSTCLASS.apps.orgProfile.prototype._setupProfileLinks = function (editProflieDiv) { var that = this; var editOverview = FIRSTCLASS.ui.Dom.getChildByClassName('fcProfileEditOverview',this._resumeDomElement); if (this._MyProfile) { if (editOverview !== null) { this._setupForGlow(editOverview,true); YAHOO.util.Event.addListener(editOverview, 'click', function() { that.ensureProfile("editProfileData"); }); } } else { var editButtons = FIRSTCLASS.ui.Dom.getChildByClassName('fcProfileEditButtons',this._resumeDomElement); if (editButtons !== null) { FIRSTCLASS.ui.Dom.setInnerHTML(editButtons,""); } } }; FIRSTCLASS.apps.orgProfile.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; } } ); 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.orgProfile.prototype._setupForGlow = function (btnElement,darkBkgrnd) { 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.orgProfile.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.orgProfile.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.orgProfile.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(); alert(FIRSTCLASS.util.BuddyList.isBuddy(that._config.params.uid));}, 3000); 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.orgProfile.prototype.baseUrl = function () { return this._config.baseUrl; }; FIRSTCLASS.apps.orgProfile.prototype.resizeEvent = function(evt) { // var theHeightTD = document.getElementById('fcProfileHeight'); // YAHOO.util.Dom.setStyle(theHeightTD,'height',YAHOO.util.Dom.getDocumentHeight()-20 + 'px'); }; FIRSTCLASS.apps.orgProfile.prototype.activate = function() { 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._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.orgProfile.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 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.orgProfile.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(); } }; FIRSTCLASS.apps.orgProfile.prototype.createAddress = function() { return document.getElementById("mainaddress").innerHTML + " " + document.getElementById("citystuff").innerHTML; }; FIRSTCLASS.apps.orgProfile.prototype.loadApplication = function(tabName, activate) { var j = -1; var that = this; if (typeof activate == "undefined") { activate = true; } // var tab = this._tabs[tabName]; for(var i = 0; i < this._subApps.length; i++) { if (this._subApps[j].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.orgProfile.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-User/' + this._config.params.cid + '/__Resume/' + 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.util.net.asyncRequest('HEAD',FIRSTCLASS.session.baseURL + '#__Open-User/' + this._config.params.cid + '/__Resume?Close=0',checkProfileCB); }; FIRSTCLASS.apps.orgProfile.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.orgProfile.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: "plain", quoteText: null, sendTo: null, op: FIRSTCLASS.opCodes.MemForm, upload: true, baseURL: FIRSTCLASS.session.baseURL }; // ensure any left over temp files are deleted first var handleFailure = function(o) { that._editor = new FIRSTCLASS.util.Message(msgCfg); }; var callback = { success:null, // set this later on, after function is defined. failure: handleFailure }; var handleSuccess = function(o) { FIRSTCLASS.util.net.asyncRequest('GET', FIRSTCLASS.util.User.getProfileUrlByCid(FIRSTCLASS.session.user.cid)+'FCXResume/profile_temp.jpg?Delete=1',callback); }; callback.success = handleSuccess; 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.orgProfile.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("Profile Picture"); 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.orgProfile.prototype.setupProfileDialog = function () { var that = this; 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) } ); this._profileDialog.validate = function () { return false; /* we handle it ourself */ }; this._profileDialog.setHeader("Edit Profile"); 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); 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.orgProfile.prototype.toggleView = function (showhideTD,dialogElem) { var html; 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"); 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.orgProfile.prototype.editProfileData = function () { this._bodyDivElement = document.createElement('div'); var msgCfg = { callback: this, element: this._bodyDivElement, objType: FIRSTCLASS.objTypes.formdoc, formID: 97, formElId: "fcProfileOverviewForm", bodyType: "plain", quoteText: null, sendTo: null, op: FIRSTCLASS.opCodes.FormEdit, baseURL: FIRSTCLASS.session.domain + FIRSTCLASS.session.baseURL + "__Open-User/" + this._config.params.cid + "/__Resume" }; this._uploadImageStep = 0; this._editor = new FIRSTCLASS.util.Message(msgCfg); }; FIRSTCLASS.apps.orgProfile.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.orgProfile.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.orgProfile.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',null); 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.orgProfile.prototype.onDisplay = function() { if (this._uploadImageStep == 1) { this._uploadImageStep = 2; this.setupImageDialog(); } else { this._createProfile = false; this.setupProfileDialog(); } }; FIRSTCLASS.apps.orgProfile.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._profileDialog.destroy(); this._profileDialog = null; this._inEditMode = false; this._createProfile = false; this._updateProfileOverview(); this._uploadImageStep = 0; } }; FIRSTCLASS.apps.orgProfile.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.orgProfile.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.orgProfile.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 + "&SaveDest=" + sharedFolder + "FCXResume/profile_original.jpg"; that._theIMG.src = theURL; } else if (that._convertStep == 3) { YAHOO.util.Dom.setStyle(document.getElementById("percentage"),"width","100%"); that._convertStep = 4; 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 == 4) { // 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.orgProfile.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; } };