/** * Class Description * @module firstclass * @title FIRSTCLASS Global */ if (typeof FIRSTCLASS == "undefined" || !FIRSTCLASS) { var FIRSTCLASS = {}; } String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ""); }; String.prototype.parseURLS = function() { var that = this; var isUrl = function(s) { var regexp = /[A-Za-z]:\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#_!:.?+=&%@!\-\/]))?/; return regexp.test(s); }; var isUrlNoProtocol = function(s) { // a little experiment - it's a link if it's got 3 dot-segments or 2 and a slash var bits = s.split("."); if (bits.length > 2) { if (bits[0].length > 0 && bits[1].length > 0 && bits[2].length > 0) { return true; } } else if (bits.length == 2 && bits[0].length > 0 && bits[1].indexOf("\/") > 0) { return true; } return false; }; var makelink = function(s) { return "" + s + ""; }; var scan = function(start, end) { var segStart = start, c = "", pos = start, seg = "", found = false; while(pos <= end) { c = pos < end ? that.charAt(pos) : ""; switch(c) { case "\n": case "\r": case " ": found = true; break; default: found = false; } if (found || pos == end) { seg = that.slice(segStart, pos); if (isUrl(seg)) { outStr += "" + seg + ""; } else if (isUrlNoProtocol(seg)) { outStr += "" + seg + ""; } else if (FIRSTCLASS.lang.isEmailAddress(seg)) { outStr += "" + seg + ""; } else { outStr += seg; } segStart = pos + 1; } if (found) { outStr += c; } pos++; } }; var inAnchor = false, // we're in an anchor converted = 0, // end offset of converted text nextOpen = 0, // next tag-open nextClose = 0, // next tag-close outStr = "", // result string uc = this.toUpperCase(); // uppercase equivalent while (converted <= this.length) { // find next tag boundary pair nextOpen = this.indexOf("<",converted); if (nextOpen >= 0) { nextClose = this.indexOf(">",nextOpen); if (nextClose < 0) { break; } } else { break; } // test and emit leading text if (nextOpen > converted) { if (inAnchor) { outStr += this.slice(converted, nextOpen); } else { scan(converted, nextOpen); } converted = nextOpen; } if (nextOpen < this.length - 1 && uc.charAt(nextOpen + 1) == "A" ) { inAnchor = true; if (nextClose > 0 && this.charAt(nextClose - 1) == "\/") { inAnchor = false; } } if (nextClose > 2 && this.charAt(nextClose - 2) == "\/" && uc.charAt(nextClose - 1) == "A") { inAnchor = false; } // emit tag text outStr += this.slice(nextOpen, nextClose + 1); converted = nextClose + 1; } // emit tail text if (converted < this.length) { scan(converted, this.length); } return outStr; }; /** * The FIRSTCLASS lang namespace * @class FIRSTCLASS.lang */ FIRSTCLASS.lang = { fcTimeToDate: function(satime) { if (typeof satime == "string") { satime = parseInt(satime); } if (typeof FIRSTCLASS.session.timezone == "string") { var hours = parseInt(FIRSTCLASS.session.timezone.substr(1,2)); var minutes = parseInt(FIRSTCLASS.session.timezone.substr(3,2)); var sign = FIRSTCLASS.session.timezone.substr(0,1) + "1"; FIRSTCLASS.session.timezone = (hours*60+minutes)*sign; } satime -= (FIRSTCLASS.session.timezone*60); var UNIXTOMAC = ((60*60*24*365*66)+(60*60*24*17)); // javascript epoch starts jan 1, 1970 // sa epoch starts Jan 1, 1904 var date = new Date(); if (satime == 0 || satime < UNIXTOMAC) { return false; } else { date.setTime((satime - UNIXTOMAC)*1000); } return date; }, ensureSlashUrl:function(uri, both) { if (typeof both != "undefined" && both && uri.charAt(0) !="/") { uri = "/" + uri; } if (uri.charAt(uri.length-1) != "/") { return uri + "/"; } else { return uri; } }, removeSlashUrl:function(uri, both) { while (both && uri.charAt(0) == "/") { uri = uri.substr(1); } while (uri.charAt(uri.length-1) == "/") { uri = uri.substr(0, uri.length-1); } return uri; }, extractSessionPath: function(uri) { var idx = uri.indexOf(FIRSTCLASS.session.baseURL); if (idx >= 0 && uri.length - idx > FIRSTCLASS.session.baseURL.length) { //uri is absolute return uri.substr(idx+FIRSTCLASS.session.baseURL.length); } else { // uri is Desktop return "Desktop"; } }, isEmailAddress: function(str) { var at="@"; var dot="."; var lat=str.indexOf(at); var lstr=str.length; var ldot=str.indexOf(dot); if (str.indexOf(at)==-1) { return false; } if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) { return false; } if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) { return false; } if (str.indexOf(at,(lat+1))!=-1) { return false; } if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) { return false; } if (str.indexOf(dot,(lat+2))==-1) { return false; } if (str.indexOf(" ")!=-1) { return false; } return true; }, // byte length calculations charLenUTF8: function(charCode) { var len = 0; if (charCode <= 127) { len = 1; } else if (charCode <= 2047) { len = 2; } else if (charCode <= 65535) { len = 3; } else { len = 4; } return len; }, strByteLenUTF8: function(str) { var len = -1; var charcode = 0; if (typeof str === "string") { for (var c = 0; c < str.length; c++) { len += FIRSTCLASS.lang.charLenUTF8(str.charCodeAt(c)); } } return len; }, strTruncUTF8: function(str, maxBytes) { var result = "", bLen = 0; for (var c = 0; c < str.length; c++) { bLen += FIRSTCLASS.lang.charLenUTF8(str.charCodeAt(c)); if (bLen > maxBytes) { break; } } result = str.slice(0,c); return result; }, // limit filename length, preserving extension and any previous munging index limitFilenameLength: function(inName) { var name = "", mungeIdx = -1, ext = ""; var dotPos = inName.lastIndexOf("."); if (dotPos >= 0) { name = inName.slice(0,dotPos); ext = inName.slice(dotPos); } else { name = inName; } var tildePos = name.lastIndexOf("~"); if ((tildePos >= 0) && (name.length <= (tildePos + 3))) { var idx = 0 + name.slice(tildePos + 1); if (!isNaN(idx)) { mungeIdx = idx; name = name.slice(0, tildePos); } } var maxBase = 63 - (ext.length + 3); // allow space for munge index if (FIRSTCLASS.lang.strByteLenUTF8(name) > maxBase) { if (mungeIdx < 1) { mungeIdx = 1; } name = FIRSTCLASS.lang.strTruncUTF8(name, maxBase); name += "~" + mungeIdx + ext; } else { if (mungeIdx >= 0) { name += "~" + mungeIdx; } name += ext; } return name; }, // return a munged filename with an incremented munge index createFilenameVariant: function(inName) { var name = "", mungeIdx = -1, ext = ""; var dotPos = inName.lastIndexOf("."); if (dotPos >= 0) { name = inName.slice(0,dotPos); ext = inName.slice(dotPos); } else { name = inName; } var tildePos = name.lastIndexOf("~"); if ((tildePos >= 0) && (name.length <= (tildePos + 3))) { var idx = 0 + name.slice(tildePos + 1); if (!isNaN(idx)) { mungeIdx = idx; name = name.slice(0, tildePos); } } var maxBase = 63 - (ext.length + 3); // allow space for munge index if (FIRSTCLASS.lang.strByteLenUTF8(name) > maxBase) { name = FIRSTCLASS.lang.strTruncUTF8(name, maxBase); } if (mungeIdx < 1) { mungeIdx = 1; } else { mungeIdx++; } name += "~" + mungeIdx + ext; return name; }, // return a thumbnail file name based on original file name createThumbName: function(inName) { var name = "", ext = ""; var dotPos = inName.lastIndexOf("."); if (dotPos >= 0) { name = inName.slice(0,dotPos); ext = inName.slice(dotPos); } else { name = inName; } if (FIRSTCLASS.lang.strByteLenUTF8(name) > 55) { name = FIRSTCLASS.lang.strTruncUTF8(name,55); } name = name + "_th"; return name + ext; }, upperCaseFirstLetter: function (str) { return str.charAt(0).toUpperCase() + str.substr(1).toLowerCase(); }, uesc: function(u) { var HD = ["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"]; var hv = function(c) { return "%"+HD[Math.floor(c/16)]+HD[c%16]; }; var s=""; for (var i=0;i>6))+hv(0x80|(c&0x3F)); } else if(c<0x10000) { s+=hv(0xE0|(c>>12))+hv(0x80|((c>>6)&0x3F))+hv(0x80|(c&0x3F)); } else { s+=hv(0xF0|(c>>16))+hv(0x80|((c>>12)&0x3F))+hv(0x80|((c>>6)&0x3F))+hv(0x80|(c&0x3F)); } } return s; }, mlesc: function(u) { var ml = {34:'"',38:'&',60:'<',62:'>',160:' ',161:'¡',162:'¢',163:'£',164:'¤',165:'¥',166:'¦',167:'§',168:'¨',169:'©',170:'ª',171:'«',172:'¬',173:'­',174:'®',175:'¯',176:'°',177:'±',178:'²',179:'³',180:'´',181:'µ',182:'¶',183:'·',184:'¸',185:'¹',186:'º',187:'»',188:'¼',189:'½',190:'¾',191:'¿',192:'À',193:'Á',194:'Â',195:'Ã',196:'Ä',197:'Å',198:'Æ',199:'Ç',200:'È',201:'É',202:'Ê',203:'Ë',204:'Ì',205:'Í',206:'Î',207:'Ï',208:'Ð',209:'Ñ',210:'Ò',211:'Ó',212:'Ô',213:'Õ',214:'Ö',215:'×',216:'Ø',217:'Ù',218:'Ú',219:'Û',220:'Ü',221:'Ý',222:'Þ',223:'ß',224:'à',225:'á',226:'â',227:'ã',228:'ä',229:'å',230:'æ',231:'ç',232:'è',233:'é',234:'ê',235:'ë',236:'ì',237:'í',238:'î',239:'ï',240:'ð',241:'ñ',242:'ò',243:'ó',244:'ô',245:'õ',246:'ö',247:'÷',248:'ø',249:'ù',250:'ú',251:'û',252:'ü',253:'ý',254:'þ',255:'ÿ'}; var s=""; for (var i=0;i0x39&&c<0x41) { r=1; } else if(c>0x5A&&c<61) { r=1; } else if(c>0x7A) { r=1; } return r; }, binary: { AND: function(a,b){ var hb=(a>=0x80000000)&&(b>=0x80000000); var r=0; if(a>=0x80000000){a-=0x80000000;} if(b>=0x80000000){b-=0x80000000;} r=a&b; if(hb){r+=0x80000000;} return r; }, OR: function(a,b){ var hb=(a>=0x80000000)||(b>=0x80000000); var r=0; if (a>=0x80000000) { a-=0x80000000; } if (b>=0x80000000) { b-=0x80000000; } r=a|b; if (hb) { r+=0x80000000; } return r; } }, string: { trim: function(sInString) { sInString = sInString.replace( /^\s+/g, "" );// strip leading return sInString.replace( /\s+$/g, "" );// strip trailing } }, serialize: function(_obj) { // Let Gecko browsers do this the easy way if (typeof _obj.toSource !== 'undefined' && typeof _obj.callee === 'undefined') { return _obj.toSource(); } // Other browsers must do it the hard way switch (typeof _obj) { // numbers, booleans, and functions are trivial: // just return the object itself since its default .toString() // gives us exactly what we want case 'number': case 'boolean': case 'function': return _obj; break; // for JSON format, strings need to be wrapped in quotes case 'string': return '\'' + _obj + '\''; break; case 'object': var str; if (_obj.constructor === Array || typeof _obj.callee !== 'undefined') { str = '['; var i, len = _obj.length; for (i = 0; i < len-1; i++) { str += this.serialize(_obj[i]) + ','; } str += this.serialize(_obj[i]) + ']'; } else { str = '{'; var key; for (key in _obj) { str += key + ':' + this.serialize(_obj[key]) + ','; } str = str.replace(/\,$/, '') + '}'; } return str; break; default: return 'UNKNOWN'; break; } }, deepCopyObjData: function(dst,src) { for (var i in src) { switch (typeof src[i]) { case "object": dst[i] = {}; FIRSTCLASS.lang.deepCopyObjData(dst[i],src[i]); break; case "function": break; default: dst[i] = src[i]; break; } } }, // Recursive object compare; returns true if all object primitive data elements of o1 // are present and equal in o2. o2 may have further elements. objDataEqual: function(o1, o2) { var t1; for (var i in o1) { t1 = typeof o1[i]; switch (t1) { case "object": if (typeof o2[i] == t1) { if (!FIRSTCLASS.lang.objDataEqual(o1[i], o2[i])) { return false; } } else { return false; } break; case "function": break; default: if (typeof o2[i] == t1) { if (o2[i] != o1[i]) { return false; } } else { return false; } break; } } return true; }, JSON: { parse: function(source, reviver) { var retval = {}; if (YAHOO.env.ua.ie < 8 && false) { retval = eval('('+source+')'); } else if (typeof JSON != "undefined" || YAHOO.env.ua.ie >= 8) { try { retval = JSON.parse(source, reviver); } catch (err) { retval = YAHOO.lang.JSON.parse(source, reviver); } } else { retval = YAHOO.lang.JSON.parse(source, reviver); } return retval; } } }; FIRSTCLASS.lexi = { isUrl: function(str) { return str.indexOf("://") > 0; }, isQuestion: function(str) { var trimmed = str.trim(); return trimmed.lastIndexOf("?") == trimmed.length - 1; } }; /** * The FIRSTCLASS util namespace * @class FIRSTCLASS.util */ if (!FIRSTCLASS.util) { FIRSTCLASS.util = { }; } FIRSTCLASS.util.parseParameters = function(urlstr) { var params = {}; var idx = urlstr.indexOf("?"); if (idx >= 0) { var parampart = urlstr.substr(idx+1); var tparams = parampart.split("&"); var param = ""; for (var i in tparams) { param = tparams[i].split("="); if (param.length) { params[param[0].toLowerCase()] = param[1]; } } } return params; }; FIRSTCLASS.util.generateThreadContextParameter = function(row, toitem) { var dtype = ""; switch(row.typedef.objtype) { case FIRSTCLASS.objTypes.odocument: dtype = "D"; break; case FIRSTCLASS.objTypes.fcfile: case FIRSTCLASS.objTypes.file: dtype = "F"; break; case FIRSTCLASS.objTypes.confitem: default: dtype = "M"; } var str = "T"+dtype+"-"+row.threadid; if (toitem) { str += "-"+row.messageid.replace("[","").replace("]","").replace(":", "-"); } return str; }; FIRSTCLASS.util.parseThreadContextParameter = function(param) { if (param.charAt(0) == "T") { var definition = {}; var parts = param.split("?"); if (parts.length) { parts = parts[0].split("-"); } else { return; } if (parts[0].length > 1) { // have objtype switch(parts[0].charAt(1)) { case "D": // odocument, oformdoc definition.objtype = FIRSTCLASS.objTypes.odocument; break; case "F": // ofile, ofcfile, otext definition.objtype = FIRSTCLASS.objTypes.file; break; case "M": // omessage, oconfitem, oform default: definition.objtype = FIRSTCLASS.objTypes.confitem; // fall-thru intentional } } if (parts.length >= 3) { definition.threadid = parts[1]+ "-" +parts[2]; } if (parts.length >= 5) { definition.messageid = "["+parts[3] + ":" + parts[4]+"]"; } return definition; } return false; }; FIRSTCLASS.util.revealContents = function() { var hider = $('fcContentHider'); YAHOO.util.Dom.setStyle(hider, 'display', 'none'); } FIRSTCLASS.util.restoreContext = function(initialPage) { var pageparts = initialPage.split("/"); if (pageparts[0].indexOf("?") > 0) { pageparts[0] = pageparts[0].substr(0, pageparts[0].indexOf("?")); } var subtype = 0; var cid = 0; var uri = ""; var params = FIRSTCLASS.util.parseParameters(initialPage); params.showoncomplete = true; var config = {title:"", showoncomplete: true}; var canrestore = false; switch(pageparts[0]) { case "__Search": canrestore = true; FIRSTCLASS.search({key:unescape(params["srch"]), escapedkey: params["srch"], showoncomplete:true}); //FIRSTCLASS.util.revealContents(); return; case "__Discover": canrestore = true; FIRSTCLASS.whatshot(params); //FIRSTCLASS.util.revealContents(); return; case "__Open-User": canrestore = true; subtype = 33; if (pageparts[1].indexOf("CID") == 0) { cid = parseInt(pageparts[1].substr(3)); config.uid = cid; uri = FIRSTCLASS.session.baseURL + "__Open-User/CID" + cid + "/__SharedDocuments/"; } if (pageparts.length > 3) { threadcontext = FIRSTCLASS.util.parseThreadContextParameter(pageparts[3]); if (threadcontext.threadid) { config.itemthread = threadcontext.threadid; } if (threadcontext.messageid) { config.messageid = threadcontext.messageid; } } break; case "__Open-Conf": canrestore = true; subtype = 66; if (pageparts[1].indexOf("CID") == 0) { cid = parseInt(pageparts[1].substr(3)); var threadcontext = false; if (pageparts.length > 2) { threadcontext = FIRSTCLASS.util.parseThreadContextParameter(pageparts[2]); if (threadcontext.threadid) { config.itemthread = threadcontext.threadid; } if (threadcontext.messageid) { config.messageid = threadcontext.messageid; } } for (var i in FIRSTCLASS.session.contentHistory) { var potentialapp = FIRSTCLASS.session.contentHistory[i]; if (potentialapp.uri.indexOf("__Open-Conf/CID" + cid) >= 0) { // found a sibling if (potentialapp.app.__fcAppName == "FIRSTCLASS.apps.Community") { potentialapp.app.loadApplication(params["tab"], true, false, true); } else { if (threadcontext.threadid && threadcontext.messageid) { potentialapp.app.getCommunity().navToItem(threadcontext.itemthread, threadcontext.messageid, true); } else if (threadcontext.threadid) { potentialapp.app.getCommunity().navToItemByThread(threadcontext.itemthread, true); } else { potentialapp.app.getCommunity().switchToApplication(params["tab"], true); } } //FIRSTCLASS.util.revealContents(); return; } } config.lconfcid = cid; uri = FIRSTCLASS.session.baseURL + "__Open-Conf/CID" + cid+"/"; if (FIRSTCLASS.apps.Desktop.instance._dataSource) { var rows = FIRSTCLASS.apps.Desktop.instance._dataSource.query("lconfcid", "" +cid, true); for(var i in rows) { uri = rows[i][1].uri; config.icon = rows[i][1].icon.uri; break; } } if (params["tab"]) { config["tab"] = params["tab"]; } } break; default: if (FIRSTCLASS.apps.Desktop.instance._dataSource) { var threadcontext = false; if (pageparts.length > 1) { threadcontext = FIRSTCLASS.util.parseThreadContextParameter(pageparts[1]); if (threadcontext.threadid) { config.itemthread = threadcontext.threadid; } if (threadcontext.messageid) { config.messageid = threadcontext.messageid; } } for (var i in FIRSTCLASS.session.contentHistory) { var potentialapp = FIRSTCLASS.session.contentHistory[i]; if (potentialapp.uri.indexOf(pageparts[0]) >= 0) { // found a sibling if (potentialapp.app.__fcAppName == "FIRSTCLASS.apps.Community") { potentialapp.app.loadApplication(params["tab"], true, false, true); } else { if (threadcontext.threadid && threadcontext.messageid) { potentialapp.app.getCommunity().navToItem(threadcontext.itemthread, threadcontext.messageid, true); } else if (threadcontext.threadid) { potentialapp.app.getCommunity().navToItemByThread(threadcontext.itemthread, true); } else { potentialapp.app.getCommunity().switchToApplication(params["tab"], true); } } //FIRSTCLASS.util.revealContents(); return; } } var testuri = pageparts[0].replace("FV", "FAV"); var rows = FIRSTCLASS.apps.Desktop.instance._dataSource.query("uri", testuri, true); if (!rows.length) { testuri = pageparts[0].replace("FV", "FOV"); } rows = FIRSTCLASS.apps.Desktop.instance._dataSource.query("uri", testuri, true); for(var i in rows) { subtype = rows[i][1].typedef.subtype; uri = rows[i][1].uri; config.icon = rows[i][1].icon.uri; config.title = rows[i][1].name; config.unread = rows[i][1].status.unread; canrestore = true; break; } } } if (canrestore) { FIRSTCLASS.loadApplication(uri, 1, subtype, config); } else { FIRSTCLASS.util.revealContents(); } }; FIRSTCLASS.util.requestToJoin = function(communitycid, subject, body) { var formcontainer = document.createElement("DIV"); var uri = FIRSTCLASS.session.baseURL + "Send?FormID=21006"; var html = ["
"]; html.push(""); html.push(""); html.push(""); html.push(""); html.push(""); html.push(""); html.push(""); html.push(""); html.push("
"); formcontainer.innerHTML = html.join(""); var msg = FIRSTCLASS.ui.Dom.getChildByClassName('fcbody', formcontainer); msg.value = body.replace(/\r/g, "
"); FIRSTCLASS.util.submitForm(formcontainer.firstChild); }; FIRSTCLASS.util.submitForm = function(form, isUpload, saveCB, action) { var useAction = action ? action : form.action; if (!isUpload) { var date = new Date(); // generate a multipart/form-data POST request var boundaryString ='--FirstClass'+date.getTime(); var boundary = "--"+boundaryString; var body = []; for (var i = 0; i < form.elements.length; i++) { var el = form.elements[i]; if (el != null && typeof el.name != "undefined" && el.name != "") { body.push(boundary); body.push('Content-Disposition: form-data; name="' + el.name + '"'); body.push(''); body.push(el.value); } } body.push(boundary+"--\r\n"); var postData = body.join("\r\n"); YAHOO.util.Connect.resetDefaultHeaders(); YAHOO.util.Connect.setDefaultPostHeader(false); YAHOO.util.Connect.initHeader('Content-Type', 'multipart/form-data; boundary=' + boundaryString); if (useAction.indexOf("?") >= 0) { useAction += "&NoKeepAlive=1"; } else { useAction += "?NoKeepAlive=1"; } return YAHOO.util.Connect.asyncRequest('POST', useAction, saveCB, postData); } else { // force the proper enctype form.enctype = "multipart/form-data"; if (YAHOO.env.ua.ie) { YAHOO.util.Connect.setForm(form, true, true); } else { YAHOO.util.Connect.setForm(form, true); } if (useAction.indexOf("?") >= 0) { useAction += "&NoKeepAlive=1"; } else { useAction += "?NoKeepAlive=1"; } return YAHOO.util.Connect.asyncRequest('POST', useAction, saveCB); } }; FIRSTCLASS.util.User = { getProfileUrlByCid: function(cid) { if (typeof cid == "string" && cid.indexOf("CID") == 0) { return FIRSTCLASS.util.User.getProfileUrlByName(cid); } else { return FIRSTCLASS.util.User.getProfileUrlByName("CID" + cid); } }, getProfileUrlByName: function(name) { return FIRSTCLASS.session.domain + FIRSTCLASS.session.baseURL + "__Open-User/" + name +"/__SharedDocuments/"; }, LatestImageTimestamp: "", updateLatestImageTimestamp: function() { FIRSTCLASS.util.User.LatestImageTimestamp = FIRSTCLASS.ui.Dom.getCurrTimestamp(); }, setLargeProfPicUrlByCid: function (theImage,cid,addDateParam, setfcattrs, fcevents, dimensions) { if (theImage != null) { var tackon = ""; theImage.src = FIRSTCLASS.util.User.getLargeProfPicUrlByCid(cid) + tackon; if (typeof setfcattrs == "undefined" || setfcattrs) { theImage.setAttribute('fcid', 'user'); theImage.setAttribute('fcattrs', ''); if (typeof cid == "string" && cid.indexOf("CID") == 0) { cid = parseInt(cid.substr(3)); } theImage.setAttribute('uid', cid); if (fcevents) { theImage.setAttribute('fcevents', fcevents); } } } }, setLargeProfPicUrlByName: function (theImage,name,addDateParam, setfcattrs, fcevents, dimensions) { if (theImage != null) { var tackon = ""; theImage.src = FIRSTCLASS.util.User.getLargeProfPicUrlByName(name) + tackon; if (typeof setfcattrs == "undefined" || setfcattrs) { theImage.setAttribute('fcid', 'user'); theImage.setAttribute('fcattrs', name); if (fcevents) { theImage.setAttribute('fcevents', fcevents); } } } }, setSmallProfPicUrlByCid: function (theImage,cid,addDateParam, setfcattrs, fcevents, dimensions, replace, thename) { if (typeof cid == "string" && cid.indexOf("CID") == 0) { cid = parseInt(cid.substr(3)); } if (theImage != null && !replace) { var tackon = ""; theImage.src = FIRSTCLASS.util.User.getSmallProfPicUrlByCid(cid) + tackon; if (typeof setfcattrs == "undefined" || setfcattrs) { theImage.setAttribute('fcid', 'user'); theImage.setAttribute('fcattrs', ''); theImage.setAttribute('uid', cid); if (fcevents) { theImage.setAttribute('fcevents', fcevents); } } if (thename) theImage.setAttribute('fcattrs', thename); } else if (replace) { var html = []; html.push(""); // var del = document.createElement("div"); theImage.innerHTML = html.join(""); // del.innerHTML = html.join(""); // theImage.parentNode.replaceChild(del.firstChild, theImage); } }, setSmallProfPicUrlByName: function (theImage,name,addDateParam, setfcattrs, fcevents) { if (theImage != null) { theImage.src = FIRSTCLASS.util.User.getSmallProfPicUrlByName(name); if (typeof setfcattrs == "undefined" || setfcattrs) { theImage.setAttribute('fcid', 'user'); theImage.setAttribute('fcattrs', name); if (fcevents) { theImage.setAttribute('fcevents', fcevents); } } } }, getSmallProfPicUrlByCid: function(cid,useUnknown) { var smallURL; var useTimeStamp = ((FIRSTCLASS.session.user.cid == cid) || ("CID"+FIRSTCLASS.session.user.cid == cid)) && (FIRSTCLASS.util.User.LatestImageTimestamp != ""); if (useTimeStamp) smallURL = FIRSTCLASS.util.User.getProfileUrlByCid(cid) + 'FCXResume/profile_50x67.jpg?'+FIRSTCLASS.util.User.LatestImageTimestamp; else smallURL = FIRSTCLASS.util.User.getProfileUrlByCid(cid) + 'FCXResume/profile_50x67.jpg'; if ((typeof useUnknown != 'undefined') && !useUnknown) return smallURL; else { if (useTimeStamp) return smallURL+'&BFProfPic=1'; else return smallURL+'?BFProfPic=1'; } }, getSmallProfPicUrlByName: function(name) { return FIRSTCLASS.util.User.getProfileUrlByName(name)+'FCXResume/profile_50x67.jpg?BFProfPic=1'; }, getLargeProfPicUrlByCid: function(cid,useUnknown) { var largeURL; var useTimeStamp = ((FIRSTCLASS.session.user.cid == cid) || ("CID"+FIRSTCLASS.session.user.cid == cid)) && (FIRSTCLASS.util.User.LatestImageTimestamp != ""); if (useTimeStamp) largeURL = FIRSTCLASS.util.User.getProfileUrlByCid(cid) + 'FCXResume/profile_135x180.jpg?'+FIRSTCLASS.util.User.LatestImageTimestamp; else largeURL = FIRSTCLASS.util.User.getProfileUrlByCid(cid) + 'FCXResume/profile_135x180.jpg'; if ((typeof useUnknown != 'undefined') && !useUnknown) return largeURL; else { if (useTimeStamp) return largeURL+'&BFProfPic=2'; else return largeURL+'?BFProfPic=2'; } }, getLargeProfPicUrlByName: function(name) { return FIRSTCLASS.util.User.getProfileUrlByName(name) + 'FCXResume/profile_135x180.jpg?BFProfPic=2'; } }; if (!FIRSTCLASS.util.BuddyList) { FIRSTCLASS.util.BuddyList= { STATUS: [ {str: "Online", icon:FIRSTCLASS.session.templatebase + "/firstclass/online.png"}, {str: "Busy", icon:FIRSTCLASS.session.templatebase + "/firstclass/online.png"}, {str: "Be Right Back", icon:FIRSTCLASS.session.templatebase + "/firstclass/online.png"}, {str: "Away", icon:FIRSTCLASS.session.templatebase + "/firstclass/online.png"}, {str: "On The Phone", icon:FIRSTCLASS.session.templatebase + "/firstclass/online.png"}, {str: "Out to Lunch", icon:FIRSTCLASS.session.templatebase + "/firstclass/online.png"}, {str: "Offline", icon:FIRSTCLASS.session.templatebase + "/firstclass/offline.png"} ], _status: 0, _message: "", getForm: function(formname) { if (formname == "buddy") { if (!FIRSTCLASS.util.BuddyList._buddyForm) { FIRSTCLASS.util.BuddyList._buddyForm = document.createElement("FORM"); var form = FIRSTCLASS.util.BuddyList._buddyForm; form.action = FIRSTCLASS.session.baseURL + "Contacts/"+FIRSTCLASS.opCodes.Create+"?What=Document&Type=11006&Close=1"; form.method = "multipart/form-data"; } return FIRSTCLASS.util.BuddyList._buddyForm; } delete FIRSTCLASS.util.BuddyList._form; FIRSTCLASS.util.BuddyList._form = document.createElement("FORM"); var form = FIRSTCLASS.util.BuddyList._form; form.action = FIRSTCLASS.session.baseURL + FIRSTCLASS.opCodes.FormSave+"?Clear=0"; return FIRSTCLASS.util.BuddyList._form; }, setStatus: function(status) { if (status < FIRSTCLASS.util.BuddyList.STATUS.length) { FIRSTCLASS.util.BuddyList._status = status; FIRSTCLASS.util.BuddyList.saveSessionData(); } }, setMessage: function(message) { FIRSTCLASS.util.BuddyList._message = message; FIRSTCLASS.util.BuddyList.saveSessionData(); }, saveSessionData: function() { // var form = FIRSTCLASS.util.BuddyList.getForm(); form.innerHTML = ''; YAHOO.util.Connect.setForm(form); YAHOO.util.Connect.asyncRequest("POST", form.action); }, addBuddy: function(name, cid,callback) { if (typeof cid == 'undefined') YAHOO.util.Connect.asyncRequest("GET", FIRSTCLASS.session.baseURL + '__Open-User/'+name+'/__SharedDocuments/?Subscribe=1',callback); else { var cidstr = cid; if (typeof cid == "string" && cid.indexOf("CID") == 0) { cidstr = cid; } else { cidstr = "CID" + cid; } YAHOO.util.Connect.asyncRequest("GET", FIRSTCLASS.session.baseURL + '__Open-User/'+cidstr+'/__SharedDocuments/?Subscribe=1',callback); } }, setDataSource: function (ds) { FIRSTCLASS.util.BuddyList._dataSource = ds; }, isBuddy: function (cid) { if (FIRSTCLASS.util.BuddyList._dataSource) { if (typeof cid == "string" && cid.indexOf("CID") == 0) { cid = cid.substr(3); } var results = FIRSTCLASS.util.BuddyList._dataSource.query("uid", cid); for (var i in results) { var aRow = results[i][1]; if ((aRow.typedef.subtype == FIRSTCLASS.subTypes.profile) && aRow.uid && (aRow.uid == cid) && (!(aRow.status) || !(aRow.status.deleted) || (aRow.status.deleted==0))) { return aRow; } } } return false; }, deleteBuddy: function(cid) { if (FIRSTCLASS.util.BuddyList._dataSource) { var results = FIRSTCLASS.util.BuddyList._dataSource.query("uid", cid); for (var i in results) { var aRow = results[i][1]; if ((aRow.typedef.subtype == FIRSTCLASS.subTypes.profile) && aRow.uid && (aRow.uid == cid)) { FIRSTCLASS.util.BuddyList._dataSource.deleteRow(results[0][1]); return true; } } } return false; } }; }; /** * The FIRSTCLASS layout namespace * @class FIRSTCLASS.layout */ if (!FIRSTCLASS.layout) { FIRSTCLASS.layout = {}; } /** * The FIRSTCLASS apps namespace * @class FIRSTCLASS.apps */ if (!FIRSTCLASS.apps) { FIRSTCLASS.apps = {}; } FIRSTCLASS.opCodes = { Attach: "__Attach", Create: "__Create", FileOp: "__FileOp", Forward: "__Forward", FormEdit: "__FormEdit", FormNew: "__FormNew", FormSave: "__FormSave", FormPost: "__FormPost", Lookup: "__Lookup", Reply: "__Reply", Send: "__Send", MemForm: "__MemForm" }; /** * The FIRSTCLASS objTypes object * @class FIRSTCLASS.objTypes */ FIRSTCLASS.objTypes = { desktop: 0, conference: 1, folder: 2, confitem: 3, message: 4, text: 5, file: 6, dirlist: 7, userlist: 9, externalfolder: 10, acl: 11, form: 12, history: 13, chat: 14, chatinvite: 15, systemmonitor: 16, formdoc: 17, hitlist: 19, memform: 20, user: 21, odocument: 22, mailbox: 24, permstationery: 31, tempstationery: 32, fcfile: 35, firmLink: 37, account: -100, search: -102, createcommunity: -103, isContainer: function(otype) { switch (otype) { case this.conference: case this.desktop: case this.folder: return true; default: return false; } } }; /** * The FIRSTCLASS subTypes object * @class FIRSTCLASS.subTypes */ FIRSTCLASS.subTypes = { mailbox: 1, conference: 2, calendar: 21, resourcecalendar: 22, locationcalendar: 23, profile: 33, tasks: 39, files: 40, workgroups: 41, trashhcan: 42, images: 44, music: 45, blog: 50, podcast: 51, community: 66 }; FIRSTCLASS.permissions = { ACL: { EDITACL: 0x00000001, MODERATOR: 0x00000002, DELETE: 0x00000004, CREATE: 0x00000008, EDIT: 0x00000010, WRITE: 0x00000020, EDITWINFO: 0x00000040, APPROVE: 0x00000080, DELETEOWN: 0x00000100, READ: 0x00000200, SEARCH: 0x00000400, SEND: 0x00000800, OPEN: 0x00001000, CRTCONF: 0x00002000, DOWNLOAD: 0x00004000, VIEWACL: 0x00008000, VIEWHIST: 0x00010000, REVERT: 0x00020000, ENABLE: 0x00040000, GETINFO: 0x00080000, OPENBYNAME: 0x00100000, VIEWDATES: 0x00200000 }, PRIV: { ADMINISTRATOR: 0x0000000000000001, UPLOAD: 0x0000000000000002, CHAT: 0x0000000000000004, MAIL: 0x0000000000000008, CONFERENCING: 0x0000000000000010, VIEWRESUMES: 0x0000000000000020, CMDLINEACCESS: 0x0000000000000040, GUIACCESS: 0x0000000000000080, SEARCH: 0x0000000000000100, CHGPREFS: 0x0000000000000200, SEEPRIVATE: 0x0000000000000400, DOWNLOAD: 0x0000000000000800, CRTCONFS: 0x0000000000001000, EDITPRIVATE: 0x0000000000002000, UNREAD: 0x0000000000004000, UNSENT: 0x0000000000008000, URGENT: 0x0000000000010000, VIEWUSERDATA: 0x0000000000020000, FORWARD: 0x0000000000040000, RECEIPT: 0x0000000000080000, AUTOMAIL: 0x0000000000100000, ADDRBOOK: 0x0000000000200000, SETEXPIRY: 0x0000000000400000, NOUSEREXPIRY: 0x0000000000800000, WORKOFFLINE: 0x0000000001000000, HOMEPAGE: 0x0000000002000000, INTERNETACCESS: 0x0000000004000000, CALENDARING: 0x0000000008000000, VOICEACCESS: 0x0000000010000000, INTERNETIMPORT: 0x0000000020000000, FILESHARING: 0x0000000040000000, CHGPASSWORD: 0x0000000080000000, VIEWPRESENCE: 0x0000000100000000, PUBLICCHAT: 0x0000000200000000, AUTOFORWARD: 0x0000000400000000, CRTRESUME: 0x0000000800000000, MAILRULES: 0x0000001000000000, MAILBOXACL: 0x0000002000000000, EDITPRESENCE: 0x0000004000000000, CALL: 0x0000008000000000, CRTCALENDAR: 0x0000010000000000, CRTCONTACT: 0x0000020000000000, EDITORGDIRNAMES: 0x0000040000000000, CRTCHAT: 0x0000080000000000, VOICEMENUS: 0x0000100000000000, COPYCLIP: 0x0000200000000000, SAVELOCAL: 0x0000400000000000, PRINTING: 0x0000800000000000, WEBACCESS: 0x0001000000000000, DIRACCESS: 0x0002000000000000, FILEACCESS: 0x0004000000000000, MAILRELAY: 0x0008000000000000, MONITORING: 0x0010000000000000, MAINTENANCE: 0x0020000000000000 }, hasPriv: function(acl, priv) { return FIRSTCLASS.lang.binary.AND(acl,priv); } }; $ = function(identifier) { return document.getElementById(identifier); }; // file icon IDs by extension FIRSTCLASS.fileTypeIcons = { // word doc: 9620, docm: 9620, docx: 9620, dot: 9620, dotm: 9620, dotx: 9620, wpm: 9620, wps: 9620, // excel slk: 9621, xla: 9621, xlam: 9621, xlc: 9621, xlm: 9621, xls: 9621, xlsb: 9621, xlsm: 9621, xlsx: 9621, xlt: 9621, xltm: 9621, xltx: 9621, // powerpoint pot: 9622, potm: 9622, potx: 9622, pps: 9622, ppt: 9622, pptm: 9622, pptx: 9622, // pdf pdf: 9623, // web htm: 9624, html: 9624, shtml: 9624, // image bmp: 9625, gif: 9625, ico: 9625, jpg: 9625, pct: 9625, pic: 9625, png: 9625, tif: 9625, // music mp3: 9626, mpp: 9626, mpv: 9626, wav: 9626, // video mov: 9627, // other document formats rtf: 9628, // generic/code formats asm: 9629, bat: 9629, c: 9629, cp: 9629, cpp: 9629, css: 9629, def: 9629, h: 9629, hpp: 9629, inc: 9629, ini: 9629, js: 9629, log: 9629, rc: 9629, rpt: 9629, shm: 9629, txt: 9629, // fc/exec formats ai: 9630, ap1: 9630, app: 9630, apt: 9630, api: 9630, bin: 9630, com: 9630, cwf: 9630, cwg: 9630, cwp: 9630, cws: 9630, dat: 9630, dbf: 9630, df1: 9630, dic: 9630, dll: 9630, dp: 9630, exe: 9630, fc: 9630, fcd: 9630, fcs: 9630, idx: 9630, mac: 9630, ovl: 9630, pm4: 9630, pm5: 9630, psd: 9630, pt4: 9630, pt5: 9630, qxd: 9630, rez: 9630, rpl: 9630, sit: 9630, sys: 9630, wks: 9630, wpd: 9630, wkz: 9630, zip: 9630 }; var CIDOfUser; /** * The FIRSTCLASS ui object, provides facilities for interacting with the browser * @class FIRSTCLASS.ui * @static */ FIRSTCLASS.ui = { /** * the current document title * * @property _docTitle * @type string * @private */ _docTitle: "", handlers: { smallProfileImageLoadFailed: function() { this.src = FIRSTCLASS.session.templatebase + '/firstclass/images/unknownUser_50x67.png' }, largeProfileImageLoadFailed: function() { this.src = FIRSTCLASS.session.templatebase + '/firstclass/images/unknownUser_135x180.png' } }, /** * the current set of instantianated widgets * * @property widgets * @type Object */ widgets: { makeValidatedNameBoxFromRow: function(row) { }, makeValidatedNameBox: function(icon, name, online) { }, buildContentBox: function(content, className) { var template=document.createElement("div"); template.innerHTML ="
"; var newfun = function(content, className) { var tmp = template.firstChild.cloneNode(true); YAHOO.util.Dom.addClass(tmp, className); var middle = FIRSTCLASS.ui.Dom.getChildByClassName('mm', tmp); FIRSTCLASS.ui.Dom.reparentNode(content, middle); return tmp; }; FIRSTCLASS.ui.widgets.buildContentBox = newfun; return newfun(content, className); }, buildContentPane: function(content, className) { var template = document.createElement("div"); var html = []; html.push(""); html.push(""); html.push(""); html.push(""); html.push(""); html.push(""); html.push(""); html.push(""); html.push("
"); if (YAHOO.env.ua.webkit) { html.push("
"); } else { html.push(""); } if (YAHOO.env.ua.ie || YAHOO.env.ua.webkit || YAHOO.env.ua.opera) { html.push(" "); // html.push(""); } html.push("
"); html.push("
"); html.push("
"); html.push("
"); template.innerHTML = html.join(""); var newfun = function(content, className) { var tmp = template.firstChild.cloneNode(true); YAHOO.util.Dom.addClass(tmp, className); YAHOO.util.Dom.addClass(content, 'fcContentWrapper'); var middle = FIRSTCLASS.ui.Dom.getChildByClassName('m', tmp); FIRSTCLASS.ui.Dom.reparentNode(content, middle); return tmp; }; FIRSTCLASS.ui.widgets.buildContentPane = newfun; return newfun(content, className); }, convertBoxToPane: function(box, className) { var middle = FIRSTCLASS.ui.Dom.getChildByClassName('mm', box); var pn = FIRSTCLASS.ui.widgets.buildContentPane(middle.firstChild, className); var parent = box.parentNode; parent.appendChild(pn); parent.removeChild(box); return pn; }, upload: function(config) { var that = this; var html = "
Uploading...
"; config.domElement.innerHTML = html; this.submit = function() { var cb = { upload: function(evt) { if (config.callbacks && config.callbacks.oncomplete) { config.callbacks.oncomplete(); } that.dispose(); } }; config.domElement.firstChild.action = FIRSTCLASS.lang.ensureSlashUrl(config.baseUrl)+FIRSTCLASS.opCodes.Attach; FIRSTCLASS.util.submitForm(config.domElement.firstChild, true, cb); // YAHOO.util.Connect.setForm(config.domElement.firstChild, true); // YAHOO.util.Connect.asyncRequest('POST', FIRSTCLASS.lang.ensureSlashUrl(config.baseUrl)+FIRSTCLASS.opCodes.Attach, cb); YAHOO.util.Dom.addClass(config.domElement.firstChild, "fcHidden"); YAHOO.util.Dom.removeClass(config.domElement.lastChild, "fcHidden"); }; this.cancel = function() { that.dispose(); }; /* YAHOO.util.Event.addListener(config.domElement.firstChild, 'submit', onsubmit);*/ this.dispose = function() { YAHOO.util.Event.purgeElement(config.domElement, true); }; this.setChangeHandler = function(handler) { YAHOO.util.Event.on('fcWidgetUpload_input', 'change', function(ev) { YAHOO.util.Event.stopEvent(ev); handler(); YAHOO.util.Event.purgeElement('fcWidgetUpload_input'); return true; }); }; }, 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.templatebase + '/firstclass/images/ButtonON' + hoverBtn + '_left.png'; YAHOO.util.Dom.setStyle(this.firstChild.nextSibling,'background-image','url(' + FIRSTCLASS.session.templatebase + '/firstclass/images/ButtonON' + hoverBtn + '_mid.png)'); this.lastChild.firstChild.src = FIRSTCLASS.session.templatebase + '/firstclass/images/ButtonON' + hoverBtn + '_right.png'; }); YAHOO.util.Event.addListener(btnElement,"mouseout", function() { this.firstChild.firstChild.src = FIRSTCLASS.session.templatebase + '/firstclass/images/ButtonOUTLINE_left.png'; YAHOO.util.Dom.setStyle(this.firstChild.nextSibling,'background-image',''); this.lastChild.firstChild.src = FIRSTCLASS.session.templatebase + '/firstclass/images/ButtonOUTLINE_right.png'; }); }, flashButton: function (btnElement) { var that = this; if (this._shine & 1) { btnElement.firstChild.firstChild.src = FIRSTCLASS.session.templatebase + '/firstclass/images/ButtonOUTLINE_left.png'; YAHOO.util.Dom.setStyle(btnElement.firstChild.nextSibling,'background-image',''); btnElement.lastChild.firstChild.src = FIRSTCLASS.session.templatebase + '/firstclass/images/ButtonOUTLINE_right.png'; } else { btnElement.firstChild.firstChild.src = FIRSTCLASS.session.templatebase + '/firstclass/images/ButtonONdark_left.png'; YAHOO.util.Dom.setStyle(btnElement.firstChild.nextSibling,'background-image','url(' + FIRSTCLASS.session.templatebase + '/firstclass/images/ButtonONdark_mid.png)'); btnElement.lastChild.firstChild.src = FIRSTCLASS.session.templatebase + '/firstclass/images/ButtonONdark_right.png'; } if (this._shine < 3) { ++this._shine; setTimeout(function() { that.flashButton(btnElement); }, 750); } }, setSubscribeBtn: function (subscribeTD,btnElement,isMyBuddy) { var that = this; if (isMyBuddy) { FIRSTCLASS.ui.Dom.setInnerHTML(btnElement,FIRSTCLASS.locale.profile.stopFollow); 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); } }, setupSubscribing: function () { var that = this; var subscribe = document.getElementById('fcMiniProfileSubscribe'); if (subscribe != null) { var btnTextElem = FIRSTCLASS.ui.Dom.getChildByClassName('fcProfileEditBtns',subscribe); that.setupForGlow(subscribe,true); that.setSubscribeBtn(null,btnTextElem,FIRSTCLASS.util.BuddyList.isBuddy(FIRSTCLASS.ui.MiniProfile.lastUID)); YAHOO.util.Event.addListener(subscribe, 'click', function() { var handleSuccess = function(o) { var wasActivate = FIRSTCLASS.util.BuddyList._dataSource.isActive(); if (!wasActivate) FIRSTCLASS.util.BuddyList._dataSource.activate(); setTimeout(function() { FIRSTCLASS.util.BuddyList._dataSource.fetchRows(); if (!wasActivate) { setTimeout(function() { FIRSTCLASS.util.BuddyList._dataSource.deactivate(); }, 3000); } }, 4000); that.setSubscribeBtn(subscribe,btnTextElem,true); }; var handleFailure = function(o) { if (btnTextElem != null) FIRSTCLASS.ui.Dom.setInnerHTML(btnTextElem,FIRSTCLASS.locale.profile.failed); }; var callback = { success:handleSuccess, failure: handleFailure }; if (FIRSTCLASS.ui.MiniProfile.lastUID) { if (FIRSTCLASS.util.BuddyList.isBuddy(FIRSTCLASS.ui.MiniProfile.lastUID)) { FIRSTCLASS.util.BuddyList.deleteBuddy(FIRSTCLASS.ui.MiniProfile.lastUID); that.setSubscribeBtn(subscribe,btnTextElem,false); } else FIRSTCLASS.util.BuddyList.addBuddy(null,FIRSTCLASS.ui.MiniProfile.lastUID,callback); } else alert("FIRSTCLASS.ui.MiniProfile.lastUID is UNDEFINED"); }); } }, showMiniProfile: function(domElement, user, callbacks, showoncomplete,showFollowBtn, neverHover) { var that = this; var handleProfile = function(response){ var setupListeners = false; var row = {}; var hasNoProfile = (response.status == "404"); try { row = FIRSTCLASS.lang.JSON.parse(response.responseText); } catch(x){ hasNoProfile = true; //YAHOO.log("JSON Parse Failed", "error", "DataSource.js"); //return; //debugger; } if ((domElement.firstChild == null) || (domElement.firstChild.id != 'miniProfilepopup')) { var tmp = []; tmp.push(""); tmp.push("
"); tmp.push("
"); tmp.push(""); tmp.push(""); tmp.push(""); tmp.push(""); tmp.push(""); tmp.push("
 
"); tmp.push(""); tmp.push(""); tmp.push(""); tmp.push("
"+ FIRSTCLASS.locale.profile.loc + "
"+ FIRSTCLASS.locale.profile.phone+ "
"+ FIRSTCLASS.locale.profile.email+ "
"); tmp.push("
profile picture edit button left marginprofile picture edit button right margin
"); tmp.push("
"); tmp.push(""); tmp.push(""); tmp.push(""); tmp.push(""); tmp.push("
"); domElement.innerHTML=tmp.join(""); setupListeners = true; } if ((typeof that.lastminiProfID == 'undefined') || (that.lastminiProfID != domElement.id)) { that.lastminiProfID = domElement.id; that.minipic = FIRSTCLASS.ui.Dom.getChildByIdName('fcMiniProfilePic',domElement); that.miniUserName = FIRSTCLASS.ui.Dom.getChildByIdName('userName', domElement); that.ministatMsg = FIRSTCLASS.ui.Dom.getChildByIdName('statusMsg', domElement); that.ministatMsgTable = FIRSTCLASS.ui.Dom.getChildByIdName('statusMsgTable', domElement); that.miniOnline = FIRSTCLASS.ui.Dom.getChildByIdName('onlineicon', domElement); that.miniWorkPos = FIRSTCLASS.ui.Dom.getChildByIdName('workPosition', domElement); that.miniWorkLocation = FIRSTCLASS.ui.Dom.getChildByIdName('workLocationRow',domElement); that.miniWorkPhone = FIRSTCLASS.ui.Dom.getChildByIdName('workPhoneRow', domElement); that.miniWorkEmail = FIRSTCLASS.ui.Dom.getChildByIdName('workEmailRow', domElement); that.toFollowOrNot = FIRSTCLASS.ui.Dom.getChildByIdName('toFollow', domElement); } if (setupListeners && ((typeof neverHover=='undefined') || !neverHover)) { YAHOO.util.Event.addListener(that.minipic,"mouseover", function() { YAHOO.util.Dom.setStyle(this,"border","2px solid #ffffff"); }); YAHOO.util.Event.addListener(that.minipic,"mouseout", function() { YAHOO.util.Dom.setStyle(this,"border","2px solid #202946"); }); YAHOO.util.Event.addListener(that.miniUserName,"mouseover", function() { YAHOO.util.Dom.setStyle(this,"text-decoration","underline"); }); YAHOO.util.Event.addListener(that.miniUserName,"mouseout", function() { YAHOO.util.Dom.setStyle(this,"text-decoration",""); }); } if (CIDOfUser != user.uid) return; that.minipic.src = FIRSTCLASS.session.templatebase + '/firstclass/images/nopixel.gif'; if (user.uid == 0) { if (user.name == "") return; FIRSTCLASS.util.User.setLargeProfPicUrlByName(that.minipic,user.name, false, true, false, false); } else { that.minipic.src = FIRSTCLASS.util.User.getLargeProfPicUrlByCid(user.uid,true); that.minipic.setAttribute('fcattrs', user.name); that.minipic.setAttribute('uid', user.uid); } if ((typeof user.name == 'undefined') || (user.name == 'undefined')) { FIRSTCLASS.ui.Dom.setInnerHTML(that.miniUserName,row.name || ""); that.miniUserName.setAttribute('fcattrs', row.name || ""); } else { FIRSTCLASS.ui.Dom.setInnerHTML(that.miniUserName,user.name); that.miniUserName.setAttribute('fcattrs', user.name); } that.miniUserName.setAttribute('uid', user.uid); if (((typeof showFollowBtn == 'undefined') || showFollowBtn) && (FIRSTCLASS.session.user.cid != user.uid)) { YAHOO.util.Dom.setStyle(that.toFollowOrNot.parentNode.parentNode,"display",""); var FollowText = FIRSTCLASS.util.BuddyList.isBuddy(FIRSTCLASS.ui.MiniProfile.lastUID) ? FIRSTCLASS.locale.profile.stopFollow : FIRSTCLASS.locale.profile.follow; FIRSTCLASS.ui.Dom.setInnerHTML(that.toFollowOrNot,FollowText); that.setupSubscribing(); } else YAHOO.util.Dom.setStyle(that.toFollowOrNot.parentNode.parentNode,"display","none"); if (hasNoProfile) { FIRSTCLASS.ui.Dom.setInnerHTML(that.miniWorkPos,"

" + FIRSTCLASS.locale.profile.othermissing); YAHOO.util.Dom.setStyle(that.miniWorkLocation,"display", "none"); YAHOO.util.Dom.setStyle(that.miniWorkPhone, "display", "none"); YAHOO.util.Dom.setStyle(that.miniWorkEmail, "display", "none"); YAHOO.util.Dom.setStyle(that.ministatMsgTable, "display", "none"); } else { if (row.message && (row.message != "")) { YAHOO.util.Dom.setStyle(that.ministatMsgTable, "display", ""); FIRSTCLASS.ui.Dom.setInnerHTML(that.ministatMsg,FIRSTCLASS.lang.mlesc(row.message).parseURLS()+'
(' + FIRSTCLASS.util.Date.getFriendlyDateTimeString(FIRSTCLASS.lang.fcTimeToDate(row.col7024)) + ')
'); } else YAHOO.util.Dom.setStyle(that.ministatMsgTable, "display", "none"); YAHOO.util.Dom.setStyle(that.miniOnline, "display", row.online ? "" : "none"); FIRSTCLASS.ui.Dom.setInnerHTML(that.miniWorkPos,row.position || ""); if (row.location && (row.location != "")) { YAHOO.util.Dom.setStyle(that.miniWorkLocation, "display", ""); FIRSTCLASS.ui.Dom.setInnerHTML(that.miniWorkLocation.firstChild.nextSibling,row.location); } else YAHOO.util.Dom.setStyle(that.miniWorkLocation, "display", "none"); if (row.phone && (row.phone != "")) { YAHOO.util.Dom.setStyle(that.miniWorkPhone, "display", ""); that.miniWorkPhone.firstChild.nextSibling.firstChild.href = "callto:" + row.phone; FIRSTCLASS.ui.Dom.setInnerHTML(that.miniWorkPhone.firstChild.nextSibling.firstChild,row.phone); } else YAHOO.util.Dom.setStyle(that.miniWorkPhone, "display", "none"); if (row.email && (row.email != "")) { YAHOO.util.Dom.setStyle(that.miniWorkEmail, "display", ""); that.miniWorkEmail.firstChild.nextSibling.firstChild.href = "mailto:" + row.email; FIRSTCLASS.ui.Dom.setInnerHTML(that.miniWorkEmail.firstChild.nextSibling.firstChild,row.email); } else YAHOO.util.Dom.setStyle(that.miniWorkEmail, "display", "none"); } var applyParams = function(el,neverHover) { if (neverHover) { if (el.getAttribute) { el.setAttribute('fcid', ''); el.setAttribute('fcevents', ''); el.setAttribute('fcattrs', ''); el.setAttribute('nohover', 'true'); el.setAttribute('uid', ''); } } else { if (el.getAttribute && (!el.getAttribute('fcid') || el.getAttribute('uid') != user.uid)) { el.setAttribute('fcid', 'user'); el.setAttribute('fcevents', 'mouseout,mouseover,mousemove'); el.setAttribute('fcattrs', row.name); el.setAttribute('nohover', 'true'); el.setAttribute('uid', user.uid); } } }; var walkNodes = function(el, func,neverHover) { func(el,neverHover); if (el.childNodes) { for (var i = 0; i < el.childNodes.length; i++) { walkNodes(el.childNodes[i],func,neverHover); } } }; walkNodes(domElement.firstChild, applyParams,neverHover); if (callbacks && callbacks.loaded) { callbacks.loaded(); } YAHOO.util.Dom.setStyle(domElement,'height',(domElement.firstChild.clientHeight + 5)+ 'px'); if (domElement.parentNode.parentNode.id == FIRSTCLASS.ui.MiniProfile.overlayBox.id) { YAHOO.util.Dom.setStyle(FIRSTCLASS.ui.MiniProfile.overlayBox,'height',(domElement.firstChild.clientHeight + 5)+ 'px'); YAHOO.util.Dom.setStyle(FIRSTCLASS.ui.MiniProfile.overlayBox.firstChild,'height',(domElement.firstChild.clientHeight + 5)+ 'px'); } if (showoncomplete) { FIRSTCLASS.ui.MiniProfile.showBoxNow(); } }; var callback = { success: handleProfile, failure: handleProfile }; var theURL = ""; if (user.uid && user.uid > 0) { theURL = FIRSTCLASS.util.User.getProfileUrlByCid(user.uid); } else { theURL = FIRSTCLASS.util.User.getProfileUrlByName(user.name); } if (theURL.indexOf("undefined") > 0) { //debugger; } theURL += "FCXResume?Templates=JS"; CIDOfUser = user.uid; var request = YAHOO.util.Connect.asyncRequest('GET', theURL, callback); }/*, miniProfile: function(hoverBox, domElement, listelement, hbox) { var callback = { loaded: function() { hoverBox.show(); }, click: function() { hbox.hide(); } }; hoverBox.hide(); FIRSTCLASS.ui.widgets.showMiniProfile(domElement, listelement, callback); }*/ }, /** * set the current document's title in the browser window and fcNavBar * * @method setDocumentTitle * @param {string} newTitle (required) the new title string * @static */ setDocumentTitle: function(newTitle) { var titleElement = $("fcNavTitle"); if (titleElement) { FIRSTCLASS.ui.navBar.setTitle(newTitle); FIRSTCLASS.ui._docTitle = newTitle; var svTitle = (FIRSTCLASS.session.serverName)?(": " + FIRSTCLASS.session.serverName):""; document.title = newTitle + svTitle; } }, Dom: { updateViewportBounds: function() { if (!this._viewportBounds) { FIRSTCLASS.ui.Dom.onViewportTimeout(); } else { if (this.viewportTimeout) { window.clearTimeout(this.viewportTimeout); } this.viewportTimeout = window.setTimeout(FIRSTCLASS.ui.Dom.onViewportTimeout, 50); } }, onViewportTimeout: function() { FIRSTCLASS.ui.Dom._viewportBounds = { //wd:YAHOO.util.Dom.getViewportWidth(), wd: YAHOO.util.Dom.getViewportWidth(), ht: YAHOO.util.Dom.getViewportHeight() }; if (FIRSTCLASS.session.getActiveApplication() && FIRSTCLASS.session.getActiveApplication().resizeEvent) { FIRSTCLASS.session.getActiveApplication().resizeEvent(); } FIRSTCLASS.ui.Dom._viewportTimeout = false; },/* updateViewportBounds: function(wd, ht) { if (!wd) { wd = document.width; } if (!ht) { ht = YAHOO.util.Dom.getViewportHeight(); } this._viewportBounds = { //wd:YAHOO.util.Dom.getViewportWidth(), wd: wd, ht: ht }; },*/ getViewportBounds: function() { if (!this._viewportBounds) { this.updateViewportBounds(); } return this._viewportBounds; }, getViewportHeight: function() { if (!this._viewportBounds) { this.updateViewportBounds(); } return this._viewportBounds.ht; }, getViewportWidth: function() { if (!this._viewportBounds) { this.updateViewportBounds(); } return this._viewportBounds.wd; }, clearElementChildren: function(element) { var newContainer = document.createElement("div"); while (element.firstChild) { var child = element.firstChild; FIRSTCLASS.ui.Dom.reparentNode(child, newContainer); } return newContainer; }, setInnerHTML: function(element, html) { try { element.innerHTML = html; } catch(e) { var tmp = document.createElement("div"); tmp.innerHTML = html; FIRSTCLASS.ui.Dom.replaceChildrenWithChildren(element,tmp); } }, replaceChildrenWithChildren: function(element, from) { var newcontainer = FIRSTCLASS.ui.Dom.clearElementChildren(element); while (from.firstChild) { var child = from.firstChild; FIRSTCLASS.ui.Dom.reparentNode(child, element); } return newcontainer; }, replaceContentsWithElement: function(element, newcontents) { var newContainer = FIRSTCLASS.ui.Dom.clearElementChildren(element); element.appendChild(newcontents); return newContainer; }, replaceContents: function(element, replace) { FIRSTCLASS.ui.Dom.clearElementChildren(element); while (replace.firstChild) { FIRSTCLASS.ui.Dom.reparentNode(replace.firstChild, element); } }, reparentNode: function(element, newparent) { var parent = element.parentNode; if (parent) { parent.removeChild(element); } newparent.appendChild(element); return parent; }, getChildByFCID: function(fcid, node) { var firstChild = YAHOO.util.Dom.getFirstChild(node) var child = firstChild; var cfcid = ""; while (child) { cfcid = child.getAttribute('fcid'); if (cfcid && cfcid == fcid) { return child; } child = YAHOO.util.Dom.getNextSibling(child); } var child = firstChild; while (child) { var tmpchild = FIRSTCLASS.ui.Dom.getChildByFCID(fcid, child); if (tmpchild) { return tmpchild; } child = YAHOO.util.Dom.getNextSibling(child); } return null; }, getChildByClassName: function(classname, node, depth) { var firstChild = YAHOO.util.Dom.getFirstChild(node) var child = firstChild; while (child) { if (YAHOO.util.Dom.hasClass(child, classname)) { return child; } child = YAHOO.util.Dom.getNextSibling(child); } var child = firstChild; while (child) { var tmpchild = FIRSTCLASS.ui.Dom.getChildByClassName(classname, child); if (tmpchild) { return tmpchild; } child = YAHOO.util.Dom.getNextSibling(child); } return null; }, getChildByIdName: function(idname, node) { var firstChild = YAHOO.util.Dom.getFirstChild(node)//.childNodes[0]; var child = firstChild; while (child) { if ((typeof child.id !== "undefined") && (child.id==idname)) { return child; } //child = child.nextSibling;// child = YAHOO.util.Dom.getNextSibling(child); } var child = firstChild; while (child) { var tmpchild = FIRSTCLASS.ui.Dom.getChildByIdName(idname, child); if (tmpchild) { return tmpchild; } //child = child.nextSibling;// child = YAHOO.util.Dom.getNextSibling(child); } return null; }, getCurrTimestamp: function () { var d = new Date(); return "time=" + d.getFullYear() + FIRSTCLASS.ui.Dom.zeroPad(d.getMonth(),2) + FIRSTCLASS.ui.Dom.zeroPad(d.getDate(),2) + FIRSTCLASS.ui.Dom.zeroPad(d.getHours(),2) + FIRSTCLASS.ui.Dom.zeroPad(d.getMinutes(),2) + FIRSTCLASS.ui.Dom.zeroPad(d.getSeconds(),2); }, zeroPad: function (num,count) { var numZeropad = num + ''; while(numZeropad.length < count) { numZeropad = "0" + numZeropad; } return numZeropad; } }, hover: { apply:function(el, hclass) { YAHOO.util.Dom.addClass(el, hclass); }, remove:function(el, hclass) { YAHOO.util.Dom.removeClass(el, hclass); } }, hoverBar: { make: function(bar, hover, control, timeout) { timeout = timeout || 1000; YAHOO.util.Event.addListener(hover,"mouseover", function() { bar.mouseOver = true; if (!hover.timeout) { hover.timeout = window.setTimeout(function() { if (bar.mouseOver) { if (control.elementWithHoverBar != hover) { FIRSTCLASS.ui.hoverBar.hide(control); } YAHOO.util.Dom.removeClass(bar, "fcHoverHidden"); control.elementWithHoverBar = hover; } }, timeout); } }); YAHOO.util.Event.addListener(hover, "mouseout", function(evt) { bar.mouseOver = false; if (!YAHOO.util.Dom.isAncestor(hover.parentNode, evt.relatedTarget) && hover != evt.relatedTarget) { hover.removeHoverBar(); } if (!YAHOO.util.Dom.isAncestor(hover, evt.relatedTarget)) { if (hover.timeout) { window.clearTimeout(hover.timeout); hover.timeout = false; } } }); hover.removeHoverBar = function() { YAHOO.util.Dom.addClass(bar, "fcHoverHidden"); }; hover.removeHoverBar(); }, hide: function(control) { if (control.elementWithHoverBar && control.elementWithHoverBar.removeHoverBar) { control.elementWithHoverBar.removeHoverBar(); control.elementWithHoverBar = false; } } }, initializeSearchBox: function(id) { var input = $(id); YAHOO.util.Event.addListener(input, "keydown", function(evt) { YAHOO.util.Event.stopPropagation(evt); }); YAHOO.util.Event.addListener(input, "keyup", function(evt) { if(evt.keyCode == 13) { FIRSTCLASS.search({key:input.value}); // top.location.hash="#__Search/?Srch=" + escape(input.value); } else if (evt.keyCode == 27) { input.typing = false; YAHOO.util.Dom.removeClass(input, "focussed"); input.value = FIRSTCLASS.locale.desktop.search; input.blur(); } YAHOO.util.Event.stopPropagation(evt); }); YAHOO.util.Event.addListener(input, "blur", function(evt) { if (input.value == "") { input.value = FIRSTCLASS.locale.desktop.search; } YAHOO.util.Dom.removeClass(input, "focussed"); }); YAHOO.util.Event.addListener(input, "focus", function(evt) { if (input.value == FIRSTCLASS.locale.desktop.search) { input.value = ""; } else { input.select(); } YAHOO.util.Dom.addClass(input, "focussed"); }); }, initializeQuickSendBox: function(id) { var input = $(id); var buildQuickSendUrl= function(str) { var postData = "BODY="+ FIRSTCLASS.lang.uesc(str) + "&Subject=" + FIRSTCLASS.lang.uesc(str) + "&BODYTYPE=PLAIN&CharSet=UTF-8&Send=1&KeepNames=1"; /*if (FIRSTCLASS.lexi.isUrl(str)) { postData += "&FormID=FIXME"; } else if(FIRSTCLASS.lexi.isQuestion(str)) { // build question postData += "&FormID=FIXME"; } else { // send message }*/ return postData; }; input.typing = false; YAHOO.util.Event.addListener(input, "keydown", function(evt) { YAHOO.util.Event.stopPropagation(evt); }); YAHOO.util.Event.addListener(input, "keyup", function(evt) { if(evt.keyCode == 13) { if (input.value == "") { return; } // enter //FIRSTCLASS.search({key:input.value}); var postData = buildQuickSendUrl(input.value); var url = FIRSTCLASS.session.getActiveObject() + "__Send"; input.value = "Sending..."; input.disabled = true; input.typing = false; input.blur(); YAHOO.util.Dom.removeClass(input, "focussed"); YAHOO.util.Connect.asyncRequest("POST", url, { success:function(o) { input.value="Send Succeeded"; input.disabled = false; }, failure: function(o) { input.value = "Send Failed"; input.disabled = false; } }, postData); } else if (evt.keyCode == 27) { input.typing = false; YAHOO.util.Dom.removeClass(input, "focussed"); input.value = "Send"; input.blur(); } else { input.typing = true; } YAHOO.util.Event.stopPropagation(evt); }); YAHOO.util.Event.addListener(input, "blur", function(evt) { if ((!input.typing || input.value == "") && input.value != "Send Succeeded" && input.value != "Sending...") { input.value = "Send"; } YAHOO.util.Dom.removeClass(input, "focussed"); }); YAHOO.util.Event.addListener(input, "focus", function(evt) { if (!input.typing) { input.value = ""; } YAHOO.util.Dom.addClass(input, "focussed"); }); }, tags: { defines: { separator: String.fromCharCode(0x02), countdelimiter: String.fromCharCode(0x03), // separator: ',', //String.fromCharCode(0x02), // countdelimiter: '.', //String.fromCharCode(0x03), legacy: { separator: ',', countdelimiter: '.' } }, arrayToServerTags: function(arrayofstrings) { return arrayofstrings.join(FIRSTCLASS.ui.tags.defines.separator) + FIRSTCLASS.ui.tags.defines.separator; } }, parseServerTags: function (stags, defaultkeys) { var cloud = []; if (stags != "") { var legacymode = false; var tags = stags.split(FIRSTCLASS.ui.tags.defines.separator); if (stags.indexOf(FIRSTCLASS.ui.tags.defines.separator) < 0) { // new mode tags are always terminated with a separator legacymode = true; tags = stags.split(FIRSTCLASS.ui.tags.defines.legacy.separator); } for (var i in tags) { var tag = tags[i]; var ts = tag.split(FIRSTCLASS.ui.tags.defines.countdelimiter); if (legacymode) { ts = tag.split(FIRSTCLASS.ui.tags.defines.legacy.countdelimiter); } if (ts.length >= 1 ){ var thetag = ts[0]; if (thetag.indexOf(""" >= 0)) { thetag = thetag.replace(/"/g, ""); } ts[0] = thetag; } var item = {"tag": ts[0],"weight": 1}; if (ts.length == 2) { item = {"tag": ts[0],"weight": parseInt(ts[1])}; } for (var i in defaultkeys) { item[i] = defaultkeys[i]; } if (item.tag) { cloud.push(item); } } } if (cloud.length > 0 && !cloud[cloud.length-1].tag) { cloud = cloud.splice(0,cloud.length-1); } return cloud; }, generateCloud: function(atagsa, makefunctiontext) { var calculateTagWeights = function(atags) { var min = -1; var max = -1; var avg = 0; for (var i in atags) { if (min == -1) { min = atags[i].weight; } if (min > atags[i].weight) { min = atags[i].weight; } if (max < atags[i].weight) { max = atags[i].weight; } avg += atags[i].weight; } var range = (max - min)/6; for (var i in atags) { var n = atags[i].weight; if (n == min) { atags[i].fw = 0; } else if (n > min && n < min + range) { atags[i].fw = 1; } else if (n >= min+range && n < min +2*range) { atags[i].fw = 2; } else if (n >= min+2*range && n < min +3*range) { atags[i].fw = 3; } else if (n >= min+3*range && n < min +4*range) { atags[i].fw = 4; } else if (n >= min+4*range && n <= max) { atags[i].fw = 5; } } }; var defaultfunctiontext = function(tag) { return "FIRSTCLASS.search({key:\"" + tag + "\"});"; }; var generateTag = function(cfg, mode) { var html = [ "" ]; if (typeof cfg.clickable == "undefined" || cfg.clickable) { if (mode) { html.push(""); } html.push(cfg.tag); if (typeof cfg.clickable == "undefined" || cfg.clickable) { html.push(""); } html.push(""); return html.join(""); }; FIRSTCLASS.ui.generateCloud = function(atags, makefunctext) { var cloud = []; calculateTagWeights(atags); for (var i = 0; i < atags.length; i++) { cloud.push(generateTag(atags[i], makefunctext)); } return cloud.join(" "); }; return FIRSTCLASS.ui.generateCloud(atagsa, makefunctiontext); }, // grab tags from a set of passed-in clouds and create a sortable list from them condenseTagClouds: function(cloud) { var list = []; var len = 0,dup; var t = {}, i,j,k; for (i = 0; i < arguments.length; i++) { if (arguments[i].length > len) { len = arguments[i].length; } } for (i= 0; i < len; i++) { for (j = 0; j < arguments.length; j++) { if (arguments[j] && arguments[j].length > i) { t = {}; t.tag = arguments[j][i].tag; t.weight = arguments[j][i].weight; dup = false; for(k = 0; k < list.length; k++) { if (list[k].tag == t.tag) { dup = true; list[k].weight += t.weight; break; } } if (!dup && (t.tag.length > 0)) { list.push(t); } } } } return list; }, generateTagDisplayList: function(atagsa, makefunctiontext) { var calculateTagRanks = function(atags) { // ordinal is nTags - tagIndex // frequency is tag.weight // rank is weighted sum of frequency and ordinal (time proximity) var ordWeight = 0.65, freqWeight = 1 - ordWeight, fRange = 1; for (var i in atags) { if (atags[i].weight > fRange) { fRange = atags[i].weight; } } for (var i in atags) { atags[i].rank = (ordWeight * (atags.length - i)/ atags.length) + (atags[i].weight * freqWeight / fRange); } }; var defaultfunctiontext = function(tag) { return "FIRSTCLASS.search({key:\"" + tag + "\"});"; }; var generateTagListItem = function(cfg, mode, last) { var html = []; if (typeof cfg.clickable == "undefined" || cfg.clickable) { if (mode) { html.push(""); } html.push(FIRSTCLASS.lang.mlesc(cfg.tag)); if (!last) { html.push(","); } if (typeof cfg.clickable == "undefined" || cfg.clickable) { html.push(""); } return html.join(""); }; var sortTagList = function(tagList) { if (tagList && tagList.length > 1) { function compareTags(a, b) { if (a.rank > b.rank) { return -1; } else if (a.rank < b.rank) { return 1; } else if (a.tag > b.tag) { return -1; } else { return 1; } } tagList.sort(compareTags); for (var i = 0; i < tagList.length; i++) { if (i >= 10) { tagList[i].tier2 = true; } } } }; FIRSTCLASS.ui.generateTagDisplayList = function(atags, makefunctext) { var dispList = []; calculateTagRanks(atags); sortTagList(atags); for (var i = 0; i < atags.length; i++) { dispList.push(generateTagListItem(atags[i], makefunctext, i >= (atags.length-1))); } return dispList.join(" "); }; return FIRSTCLASS.ui.generateTagDisplayList(atagsa, makefunctiontext); }, mergeTagClouds: function(cloud1, cloud2) { var outcloud = []; for (var i in cloud1) { outcloud.push(cloud1[i]); } for (var i in cloud2) { var found = false; for (var j in outcloud) { if (outcloud[j].tag == cloud2[i].tag) { outcloud[j].weight += cloud2[i].weight; found = true; break; } } if (!found) { outcloud.push(cloud2[i]); } } return outcloud; }, cloudToServerTags: function(cloud) { var tgs = []; for (var i in cloud) { tgs.push(cloud[i].tag + FIRSTCLASS.ui.tags.defines.countdelimiter + cloud[i].weight); } return tgs.join(FIRSTCLASS.ui.tags.defines.separator) + FIRSTCLASS.ui.tags.defines.separator; }, skin: { currentSkin: false, skins: {}, set: function(string) { if (this.currentSkin && this.currentSkin == string) { return; } else if (this.currentSkin) { this.clear(); } if (this.timeout) { this.clear(); } if (string.length > 0) { var that = this; this.insert(string); // precache background.jpg YAHOO.util.Connect.asyncRequest("GET", FIRSTCLASS.session.templatebase +"/firstclass/resources/skins/"+ string+"/skin.pjs", { success: function(response) { var obj = {}; var html = []; try { obj = FIRSTCLASS.lang.JSON.parse(response.responseText); if (obj.images) { var loaded = []; var images = []; for (var i in obj.images) { var img = new Image(); img.src = obj.images[i]; loaded[i] = false; images[i] = img; } var checkLoaded = function() { if (that.currentSkin == string) { var allcomplete = true; for (var i in images) { if (!images[i].complete) { allcomplete = false; } } if (allcomplete) { // loaded, apply the skin YAHOO.util.Dom.addClass(document.body, 'fcSkin'+string); // TODO: cleanup } else { that.timeout = window.setTimeout(checkLoaded, 10); } } }; checkLoaded(); } } catch (e) { } } }); } this.currentSkin = string; }, clear: function() { if (this.timeout) { window.clearTimeout(this.timeout); this.timeout = false; } var bodycnames = document.body.className.split(" "); for (var i in bodycnames) { if (bodycnames[i].indexOf('fcSkin') >= 0) { YAHOO.util.Dom.removeClass(document.body, bodycnames[i]); } } this.currentSkin = false; }, get: function() { return this.currentSkin; }, insert: function(string) { if (!this.skins[string]) { var that = this; var skinName = "fcSkins"//Css" + string; var added = FIRSTCLASS._loader.addModule({ name: skinName, type: "css", //fullpath: FIRSTCLASS.session.templatebase + "/firstclass/resources/skins/"+string+"/skin.pcss" fullpath: FIRSTCLASS.session.templatebase + "/firstclass/resources/skins/allskins.pcss" }); FIRSTCLASS._loader.require([skinName]); FIRSTCLASS._loader.onSuccess = function(o) { that.skins[string]=skinName; }; FIRSTCLASS._loader.insert(); } } }, scrollChildrenIntoView: function(parent, topChild, bottomChild, totop) { if (!YAHOO.util.Dom.isAncestor(parent, topChild)) { return; } if (typeof bottomChild == "undefined") { bottomChild = topChild; } if (!YAHOO.util.Dom.isAncestor(parent, bottomChild)) { return; } // scroll if required var vPort = { top: parent.scrollTop, bottom: parent.scrollTop + parent.clientHeight }, sel = { top: topChild.offsetTop, bottom: bottomChild.offsetTop + bottomChild.clientHeight }; if (totop) { parent.scrollTop = sel.top; } else { if (sel.bottom > vPort.bottom) { parent.scrollTop += sel.bottom - vPort.bottom; } if (sel.top < vPort.top) { parent.scrollTop -= vPort.top - sel.top; } } }, embeds: { handleClick: function(fcevent, itemurl) { var attrs = fcevent.fcattrs.split(";"); var w = attrs[1] - 0; var h = attrs[2] - 0; w += 75; h += 50; YAHOO.util.Dom.removeClass(fcevent.target,'fcEmbed'); YAHOO.util.Dom.addClass(fcevent.target,'fcEmbed-active'); fcevent.target.innerHTML = ""; var frame = fcevent.target.firstChild; var resize = new YAHOO.util.Resize(frame, { height: h, width: w, minX: 200, minY: 100, setSize: true, handles: ['br'], proxy: true, ghost: true }); } } }; FIRSTCLASS.ui.MiniProfile = { width: 450, height: 250, overlap: 5, shown: false, timeout: 800, timeoutToHide: 400, showTimeout: 0, hideTimeout: 0, mouseHasLeft: false, zindex: 100, anchorElement: null, userinfo: null, lastClientX: -1, lastClientY: -1, show: function() { anchorElement = this.anchorElement; userinfo = this.userinfo; if (this.showTimeout) { window.clearTimeout(this.showTimeout); this.showTimeout = 0; } if (this.hideTimeout) { window.clearTimeout(this.hideTimeout); this.hideTimeout = 0; } if (anchorElement != this.domElement && anchorElement != this.currentAnchor) { if (!this.overlay) { this.overlay = new YAHOO.widget.Overlay("fcMiniProfileOverlay", { visible:false, width: this.width+"px", height: this.height+"px", zIndex: this.zindex} ); this.domElement = document.createElement("DIV"); this.domElement.id = 'fcMiniProfilePopup'; this.overlay.setBody(this.domElement); // this.overlay.hideMacGeckoScrollbars(); this.overlay.render(document.body);//$("fcHiddenDiv")); this.overlayBox = $("fcMiniProfileOverlay"); } if ((!this.lastUID && userinfo.cid && (userinfo.cid >= 0)) || (this.lastUID != userinfo.uid)) { this.nextUser = userinfo; } else if (!this.lastUID || (this.lastName != userinfo.name)) { this.nextUser = userinfo; userinfo.cid = -1; } this.nextAnchor = anchorElement; } else if (!this.shown) { this.nextUser = userinfo; } this.processBox(); }, processBox: function() { var userinfo = this.nextUser; var anchorElement = this.nextAnchor; this.domElement.setAttribute('fcid', 'user'); this.domElement.setAttribute('fcattrs', userinfo.name); this.domElement.setAttribute('uid', userinfo.uid); this.domElement.setAttribute('fcevents', 'mouseover,mouseout'); var rgn = YAHOO.util.Region.getRegion(anchorElement); var maxHoverboxHeight = 220; var doctop = YAHOO.util.Dom.getDocumentScrollTop(); var viewport = FIRSTCLASS.ui.Dom.getViewportBounds(); var docheight = viewport.ht; var docwidth = viewport.wd; var overflow = this.width-this.overlap; rgn.top -= 80; var position = []; if (rgn.top < doctop + 10) rgn.top = doctop + 10; else if (rgn.top + maxHoverboxHeight > doctop + docheight) rgn.top = doctop + docheight - maxHoverboxHeight; if (rgn.right + overflow < viewport.wd) { position = [rgn.right - this.overlap, rgn.top]; } else if (rgn.left - overflow >= 0) { position = [rgn.left - overflow, rgn.top]; } else if (docwidth - rgn.right > rgn.left) { position = [docwidth-overflow, rgn.top]; } else { position = [0, rgn.top]; } this.nextPosition = position; if (this.nextUser && this.lastUID != this.nextUser.uid) { FIRSTCLASS.ui.widgets.showMiniProfile(this.domElement, userinfo, false, true); } else if (!FIRSTCLASS.ui.MiniProfile.shown) { FIRSTCLASS.ui.MiniProfile.showBoxNow(); } if (this.nextUser) { this.lastUID = this.nextUser.uid; this.lastName = this.nextUser.name; } this.nextUser = false; this.currentAnchor = anchorElement; }, showBox: function() { if (FIRSTCLASS.ui.MiniProfile.url == location.href) FIRSTCLASS.ui.MiniProfile.show(); else FIRSTCLASS.ui.MiniProfile.url = ""; }, showBoxNow: function() { if (!FIRSTCLASS.ui.MiniProfile.mouseHasLeft) { YAHOO.util.Dom.setStyle(FIRSTCLASS.ui.MiniProfile.overlayBox, "display", "block"); FIRSTCLASS.ui.MiniProfile.overlay.cfg.setProperty("xy",FIRSTCLASS.ui.MiniProfile.nextPosition); if (YAHOO.env.ua.ie) { FIRSTCLASS.ui.MiniProfile.overlay.show(); FIRSTCLASS.ui.MiniProfile.shown = true; } else { FIRSTCLASS.ui.MiniProfile.fadeSetting = 20; YAHOO.util.Dom.setStyle(FIRSTCLASS.ui.MiniProfile.domElement.firstChild,"MozOpacity",""+FIRSTCLASS.ui.MiniProfile.fadeSetting/100); YAHOO.util.Dom.setStyle(FIRSTCLASS.ui.MiniProfile.domElement.firstChild,"opacity",""+FIRSTCLASS.ui.MiniProfile.fadeSetting/100); YAHOO.util.Dom.setStyle(FIRSTCLASS.ui.MiniProfile.domElement.firstChild,"KhtmlOpacity",""+FIRSTCLASS.ui.MiniProfile.fadeSetting/100); // YAHOO.util.Dom.setStyle(FIRSTCLASS.ui.MiniProfile.domElement.firstChild,"filter:","alpha(opacity='" + FIRSTCLASS.ui.MiniProfile.fadeSetting + "')" ); FIRSTCLASS.ui.MiniProfile.overlay.show(); FIRSTCLASS.ui.MiniProfile.shown = true; FIRSTCLASS.ui.MiniProfile.timeout = 750; this.fadeTimeInOut = window.setTimeout(FIRSTCLASS.ui.MiniProfile.fadeIn,10); } } }, fadeIn: function () { if (FIRSTCLASS.ui.MiniProfile.shown && (FIRSTCLASS.ui.MiniProfile.fadeSetting < 100)) { FIRSTCLASS.ui.MiniProfile.fadeSetting += 10; YAHOO.util.Dom.setStyle(FIRSTCLASS.ui.MiniProfile.domElement.firstChild,"MozOpacity",""+FIRSTCLASS.ui.MiniProfile.fadeSetting/100); YAHOO.util.Dom.setStyle(FIRSTCLASS.ui.MiniProfile.domElement.firstChild,"opacity",""+FIRSTCLASS.ui.MiniProfile.fadeSetting/100); YAHOO.util.Dom.setStyle(FIRSTCLASS.ui.MiniProfile.domElement.firstChild,"KhtmlOpacity",""+FIRSTCLASS.ui.MiniProfile.fadeSetting/100); // YAHOO.util.Dom.setStyle(FIRSTCLASS.ui.MiniProfile.domElement.firstChild,"filter:","alpha(opacity='" + FIRSTCLASS.ui.MiniProfile.fadeSetting + "')" ); this.fadeTimeInOut = window.setTimeout(FIRSTCLASS.ui.MiniProfile.fadeIn,50); } else YAHOO.util.Dom.setStyle(FIRSTCLASS.ui.MiniProfile.domElement.firstChild,"filter:",""); }, hideBoxNow: function() { if (FIRSTCLASS.ui.MiniProfile.overlay) { FIRSTCLASS.ui.MiniProfile.overlay.hide(); FIRSTCLASS.ui.MiniProfile.timeout = 800; } FIRSTCLASS.ui.MiniProfile.shown = false; }, dispatchShow: function(_anchorElement,_userinfo) { this.anchorElement = _anchorElement; this.userinfo = _userinfo; this.url = location.href; this.showTimeout = window.setTimeout(FIRSTCLASS.ui.MiniProfile.showBox, this.timeout); if (this.hideTimeout) { window.clearTimeout(this.hideTimeout); this.hideTimeout = 0; } }, resetOnMove: function (event,fcEvent) { if ((Math.abs(this.lastClientX-event.clientX)> 3) || (Math.abs(this.lastClientY-event.clientY)> 3)) { this.lastClientX = event.clientX; this.lastClientY = event.clientY; if (this.showTimeout) { window.clearTimeout(this.showTimeout); this.showTimeout = 0; } if (!FIRSTCLASS.ui.MiniProfile.shown || (this.showTimeout == 0)) { this.showTimeout = window.setTimeout(this.showBox,FIRSTCLASS.ui.MiniProfile.timeout); } } }, mouseout: function(event) { FIRSTCLASS.ui.MiniProfile.mouseHasLeft = true; if (this.overlay && this.shown) { this.hideTimeout = window.setTimeout(FIRSTCLASS.ui.MiniProfile.hideBoxNow, this.timeoutToHide); } if (this.showTimeout) { window.clearTimeout(this.showTimeout); this.showTimeout = 0; } } }; FIRSTCLASS.ui.toolBar = function(config) { var hover = null; var buttons = []; var that = this; YAHOO.util.Dom.addClass(config.domElement,"fcToolBar"); if (config.vertical) { YAHOO.util.Dom.addClass(config.domElement,"fcToolBarVertical"); this._domEl = config.domElement; } else { var html = []; html.push(""); html.push(""); html.push("
 
"); config.domElement.innerHTML = html.join(""); this._domEl = config.domElement.childNodes[0].childNodes[0].childNodes[0].childNodes[1]; } var makeButton = function(theButton, buttoncfg, acl) { //YAHOO.util.Event.purgeElement(theButton, true); if (typeof buttoncfg.customizer == "function") { buttoncfg.customizer(theButton, buttoncfg, acl); } if (buttoncfg.fcid) { theButton.setAttribute('fcid', buttoncfg.fcid); } if (buttoncfg.fcattrs) { theButton.setAttribute('fcattrs', buttoncfg.fcattrs); } if (buttoncfg.click) { YAHOO.util.Event.addListener(theButton, "click", function(evt){ buttoncfg.click(evt, that.parameter); }); } }; this.addButton = function(buttoncfg) { var theButton = document.createElement("div"); if (this._domEl.lastChild) { YAHOO.util.Dom.removeClass(this._domEl.lastChild, "fcToolBarLastButton"); } this._domEl.appendChild(theButton); /*if (buttoncfg.label.indexOf("|") >= 0) { var parts = buttoncfg.label.split("|"); buttoncfg.label = parts[0]; buttoncfg.tooltip = parts[1]; }*/ switch (buttoncfg.type) { case "ralign": YAHOO.util.Dom.addClass(theButton,"fcToolBarButton"); break; case "find": YAHOO.util.Dom.addClass(theButton,"fcToolBarButton"); break; case "disclosure": var disclosureButtons = ['
Minimal
']; /*disclosureButtons.push('
Subjects
'); disclosureButtons.push('
Previews
');*/ disclosureButtons.push('
All
'); theButton.innerHTML=disclosureButtons.join(""); YAHOO.util.Event.onAvailable(buttoncfg.id+"DiscloseBodies", function() { buttoncfg.none = $(buttoncfg.id + "DiscloseNone"); // buttoncfg.subjects = $(buttoncfg.id + "DiscloseSubjects"); // buttoncfg.previews = $(buttoncfg.id + "DisclosePreviews"); buttoncfg.bodies = $(buttoncfg.id + "DiscloseBodies"); makeButton(buttoncfg.none, buttoncfg); // makeButton(buttoncfg.subjects); // makeButton(buttoncfg.previews); makeButton(buttoncfg.bodies, buttoncfg); YAHOO.util.Event.addListener(buttoncfg.none, "click", function(evt) { buttoncfg.change(0); }); /* YAHOO.util.Event.addListener(buttoncfg.subjects, "click", function(evt) { buttoncfg.change(50); }); YAHOO.util.Event.addListener(buttoncfg.previews, "click", function(evt) { buttoncfg.change(100); });*/ YAHOO.util.Event.addListener(buttoncfg.bodies, "click", function(evt) { buttoncfg.change(150); }); }); YAHOO.util.Dom.addClass(theButton,"fcDisclosureControl"); /* // slider control theButton.innerHTML='
'; theButton.id = buttoncfg.id; buttoncfg.slider = YAHOO.widget.Slider.getHorizSlider(buttoncfg.id+"disclose", buttoncfg.id+"thumb", 0, 150, 50); YAHOO.util.Event.onAvailable(buttoncfg.id+"thumb", function() { buttoncfg.slider.setValue(150, 1, 1, false); }); */ break; case "checked": YAHOO.util.Dom.addClass(theButton, "fcToolBarButton"); FIRSTCLASS.locale.setElementString(buttoncfg.label, theButton, "$content$"); // theButton.innerHTML = buttoncfg.label + ""; break; case "unchecked": YAHOO.util.Dom.addClass(theButton, "fcToolBarButton"); FIRSTCLASS.locale.setElementString(buttoncfg.label, theButton, "$content$"); //getStringParts(string) // theButton.innerHTML = buttoncfg.label; break; // case "button": default: YAHOO.util.Dom.addClass(theButton,"fcToolBarButton"); FIRSTCLASS.locale.setElementString(buttoncfg.label, theButton, "$content$"); // theButton.innerHTML = buttoncfg.label; } /*if (buttoncfg.tooltip) { theButton.setAttribute("title", buttoncfg.tooltip); }*/ theButton.id = buttoncfg.id; buttons[buttoncfg.id] = theButton; switch (buttoncfg.type) { case "ralign": // do nothing break; case "disclosure": /*if (buttoncfg.change) { buttoncfg.slider.subscribe("slideEnd", function() { if (isNaN(buttoncfg.slider.thumb.startOffset[0]) || isNaN(buttoncfg.slider.thumb.startOffset[1])) { buttoncfg.slider.thumb.startOffset = buttoncfg.slider.thumb.getOffsetFromParent(); } if (!buttoncfg.thumb) { buttoncfg.thumb = $(buttoncfg.id+"thumb"); } buttoncfg.change(parseInt(YAHOO.util.Dom.getStyle(buttoncfg.thumb, "left"), 0)); }); }*/ break; case "find": break; //case "button": default: makeButton(theButton, buttoncfg); } if (buttoncfg.priv || buttoncfg.condition) { YAHOO.util.Dom.setStyle(theButton, "display", "none"); } YAHOO.util.Dom.addClass(this._domEl.lastChild, "fcToolBarLastButton"); }; this.removeButton = function(buttonid) { var buttonelem = buttons[buttonid]; // var buttonelem = FIRSTCLASS.ui.Dom.getChildByIdName(buttonid,this._domEl); if (buttonelem) { this._domEl.removeChild(buttonelem); YAHOO.util.Event.purgeElement(buttonelem); buttons[buttonid] = false; } }; this.hideButton = function(buttonid) { var buttonelem = buttons[buttonid]; if (buttonelem) { YAHOO.util.Dom.setStyle(buttonelem, "display", "none"); YAHOO.util.Dom.removeClass(buttonelem, 'fcToolBarLastButton'); } }; this.showButton = function(buttonid) { var buttonelem = buttons[buttonid]; if (buttonelem) { YAHOO.util.Dom.setStyle(buttonelem, "display", ""); if (this._lastButton !== null) { YAHOO.util.Dom.removeClass(this._lastButton, 'fcToolBarLastButton'); } YAHOO.util.Dom.addClass(buttonelem, 'fcToolBarLastButton'); this._lastButton = buttonelem; } }; // reconfigure the toolbar, passing param to the condition handler this.reconfigure = function(param, acl) { var buttonelem; this._lastButton = null; for (var i in config.buttons) { if (acl && (config.buttons[i].priv && FIRSTCLASS.permissions.hasPriv(acl, config.buttons[i].priv) == config.buttons[i].priv) || !config.buttons[i].priv) { buttonelem = buttons[config.buttons[i].id]; if (config.buttons[i].condition) { makeButton(buttonelem, config.buttons[i]); if (config.buttons[i].condition(param)) { this.showButton(config.buttons[i].id); } else { this.hideButton(config.buttons[i].id); } } else { this.showButton(config.buttons[i].id); if (config.buttons[i].customizer) { makeButton(buttonelem, config.buttons[i], acl); } } } else { this.hideButton(config.buttons[i].id); } } this.parameter = param; }; // update label for existing button this.setButtonLabel = function(buttonid,label) { for (var i in config.buttons) { if (config.buttons[i].id == buttonid) { var btn = buttons[buttonid]; if (btn) { FIRSTCLASS.locale.setElementString(label, btn); config.buttons[i].label = label; /*var tooltip = config.buttons[i].tooltip; if (label.indexOf("|") >= 0) { var parts = label.split("|"); label = parts[0]; tooltip = parts[1]; } btn.innerHTML = label; if (tooltip) { btn.setAttribute("title", tooltip); } config.buttons[i].label = label; config.buttons[i].tooltip = tooltip;*/ } break; } } }; for (var button in config.buttons) { this.addButton(config.buttons[button]); } }; FIRSTCLASS.ui.sideBar = function(domElement, hide) { this._domElement = domElement; this._templateBox = document.createElement("div"); this._hidden = true; var template = []; template.push(""); template.push(""); template.push(""); template.push(""); template.push("
"); this._templateBox.innerHTML = template.join(""); this._appboxes = {}; }; FIRSTCLASS.ui.sideBar.prototype.getStaticBox = function() { var child = FIRSTCLASS.ui.Dom.getChildByClassName("fcSideBarStaticContents", this._domElement); children = null; if (typeof child == "undefined") { child = document.createElement("div"); YAHOO.util.Dom.addClass("fcSideBarStaticContents", child); if (this._domElement.firstChild) { YAHOO.util.Dom.insertBefore(child, this._domElement.firstChild); } else { this._domElement.appendChild(child); } } this.getStaticBox = function() { return child; } return child; }; FIRSTCLASS.ui.sideBar.prototype.getApplicationBox = function() { var child = FIRSTCLASS.ui.Dom.getChildByClassName("fcSideBarApplicationContents", this._domElement); if (typeof child == "undefined") { child = document.createElement("div"); YAHOO.util.Dom.addClass("fcSideBarApplicationContents", child); this._domElement.appendChild(child); } this.getApplicationBox = function() { return child; }; return child; }; FIRSTCLASS.ui.sideBar.prototype.getApplicationBoxBounds = function() { var staticContents = this.getStaticBox(); var fn = function() { var rgn = YAHOO.util.Dom.getRegion(staticContents); var bounds = {w:rgn.right - rgn.left, h:FIRSTCLASS.ui.Dom.getViewportHeight()-rgn.bottom}; return bounds; }; this.getApplicationBoxBounds = fn; return fn(); }; FIRSTCLASS.ui.sideBar.prototype.getWidth = function() { if (this._hidden) { return 0; } return 180; }; FIRSTCLASS.ui.sideBar.prototype.hide = function() { YAHOO.util.Dom.setStyle(this._domElement.parentNode, "display", "none"); this._hidden = true; }; FIRSTCLASS.ui.sideBar.prototype.isHidden = function() { return this._hidden; }; FIRSTCLASS.ui.sideBar.prototype.show = function(animate, oncomplete) { if (animate && YAHOO.util.Anim) { YAHOO.util.Dom.setStyle(this._domElement.parentNode, 'min-width', '0px'); YAHOO.util.Dom.setStyle(this._domElement.parentNode, 'width', '0px'); } if (YAHOO.env.ua.ie == 0) { YAHOO.util.Dom.setStyle(this._domElement.parentNode, "display", "table-cell"); } else { YAHOO.util.Dom.setStyle(this._domElement.parentNode, "display", ""); } if (animate && YAHOO.util.Anim) { var w = FIRSTCLASS.ui.Dom.getViewportWidth()*0.2; if (w < 180) { w = 180; } var attributes = { width: { to: w } }; var that = this; var f = function() { YAHOO.util.Dom.setStyle(that._domElement.parentNode, 'min-width', ''); YAHOO.util.Dom.setStyle(that._domElement.parentNode, 'width', ''); if (oncomplete) { oncomplete(); } }; var anim = new YAHOO.util.Anim(this._domElement.parentNode, attributes); //anim.method = YAHOO.util.Easing.easeOut; anim.duration = 1; anim.onComplete.subscribe(f); anim.animate(); } if (!anim && oncomplete) { oncomplete(); } this._hidden = false; }; FIRSTCLASS.ui.sideBar.prototype.resetApplicationBoxContents = function() { return FIRSTCLASS.ui.Dom.clearElementChildren(this.getApplicationBox()); }; FIRSTCLASS.ui.sideBar.prototype.setApplicationBoxContents = function(domElement) { return FIRSTCLASS.ui.Dom.replaceContentsWithElement(FIRSTCLASS.ui.sideBar.getApplicationBox(), domElement); }; FIRSTCLASS.ui.sideBar.prototype.addApplicationBox = function(domElement, pTitle, action, invisible, isvariable, atitle, noscroll, fcid) { var container = this._templateBox.cloneNode(true); YAHOO.util.Dom.addClass(container, "fcSideBarContainer"); if (invisible) YAHOO.util.Dom.setStyle(container,"display","none"); var tablehead = FIRSTCLASS.ui.Dom.getChildByClassName("fcSBHeader", container); var tablesubhead = FIRSTCLASS.ui.Dom.getChildByClassName("fcSBSubHeader", container); var tablebody = FIRSTCLASS.ui.Dom.getChildByClassName("fcSBContent", container); var title = document.createElement("div"); YAHOO.util.Dom.addClass(title, "hd"); var titleElem = document.createElement("h2"); FIRSTCLASS.locale.setElementString(pTitle, titleElem); // titleElem.innerHTML = pTitle; title.appendChild(titleElem); container.sTitle = pTitle; var body = domElement; YAHOO.util.Dom.addClass(body, "bd"); container.hd = title; container.bd = body; container.shd = tablesubhead; if (isvariable) { container.isvariable = isvariable; if (!noscroll) { YAHOO.util.Dom.setStyle(body, 'overflow', 'auto'); } } tablehead.appendChild(title); tablebody.appendChild(body); YAHOO.util.Dom.setStyle(tablebody, 'vertical-align', 'top'); if (domElement.fixedHeight) { container.fixedHeight = domElement.fixedHeight;} if (domElement.minHeight) { container.minHeight = domElement.minHeight;} if (domElement.maxHeight) { container.maxHeight = domElement.maxHeight;} this.getApplicationBox().appendChild(container); this._appboxes[pTitle] = container; if (action) { this.updateBoxAction(pTitle, action, atitle, fcid); } }; FIRSTCLASS.ui.sideBar.prototype.updateBoxAction = function(pTitle, newaction, atitle, fcid) { var box = this._appboxes[pTitle]; if (box) { var title = document.createElement("div"); var titleElem = document.createElement("h2"); FIRSTCLASS.locale.setElementString(pTitle, titleElem); // titleElem.innerHTML = pTitle; if (newaction || fcid) { var butt = false; if (typeof newaction == "string") { butt = document.createElement("A"); YAHOO.util.Dom.addClass(butt, 'fcHeaderAction'); if (fcid) { butt.setAttribute('fcid', newaction); } else { butt.href = newaction; } butt.innerHTML = atitle; } else { butt = document.createElement("div"); if (fcid) { butt.setAttribute('fcid', fcid); } else { YAHOO.util.Event.addListener(butt, "click", newaction); } YAHOO.util.Dom.addClass(butt,"fcHeaderPlusButton"); } title.appendChild(butt); } title.appendChild(titleElem); FIRSTCLASS.ui.Dom.replaceContents(box.hd, title); } }; FIRSTCLASS.ui.sideBar.prototype.updateBoxContents = function(pTitle, newcontents) { var box = this._appboxes[pTitle]; if (box) { FIRSTCLASS.ui.Dom.replaceContentsWithElement(box.bd, newcontents); } }; FIRSTCLASS.ui.sideBar.prototype.updateBoxSubHeader = function(pTitle, newcontents) { var box = this._appboxes[pTitle]; if (box) { FIRSTCLASS.ui.Dom.replaceContentsWithElement(box.shd, newcontents); } }; FIRSTCLASS.ui.sideBar.prototype.removeApplicationBox = function(pTitle) { var container = this._appboxes[pTitle]; if (container) { this.getApplicationBox().removeChild(container); this._appboxes[pTitle] = null; } }; FIRSTCLASS.ui.sideBar.hideApplicationBox = function(ptitle) { FIRSTCLASS.ui.leftSideBar.hideApplicationBox(ptitle); FIRSTCLASS.ui.rightSideBar.hideApplicationBox(ptitle); }; FIRSTCLASS.ui.sideBar.prototype.hideApplicationBox = function(pTitle) { var container = this._appboxes[pTitle]; if (container) { YAHOO.util.Dom.setStyle(container, "display", "none"); } }; FIRSTCLASS.ui.sideBar.showApplicationBox = function(ptitle) { FIRSTCLASS.ui.leftSideBar.showApplicationBox(ptitle); FIRSTCLASS.ui.rightSideBar.showApplicationBox(ptitle); }; FIRSTCLASS.ui.sideBar.prototype.showApplicationBox = function(pTitle) { var container = this._appboxes[pTitle]; if (container) { YAHOO.util.Dom.setStyle(container, "display", ""); } }; FIRSTCLASS.ui.sideBar.prototype.isApplicationBoxVisible = function(pTitle) { var container = this._appboxes[pTitle]; if (container) { var display = YAHOO.util.Dom.getStyle(container, "display"); return display != "none"; } return false; }; FIRSTCLASS.ui.sideBar.prototype.adjustBoxHeights = function(ht) { // var bounds = this.getApplicationBoxBounds(); var box = this.getApplicationBox(); var that = this; //var nChildren = this._appboxes.length; //box.childNodes.length; var f = function(c, h) { //YAHOO.util.Dom.setStyle(c, "height", "" + h + "px"); //var hdrgn = YAHOO.util.Dom.getRegion(c.hd); //var ht = h - (hdrgn.bottom-hdrgn.top); var padding = 50; var ht = h-padding; if (ht < 0) { ht = 0; } var chunkiness = c.isvariable; var mod = ht % chunkiness; if (!isNaN(mod) && !isNaN(ht)) { YAHOO.util.Dom.setStyle(c.bd, "height", "" + (ht-mod) +"px"); } }; var availableht = ht; var variable = false; var steps = 0; var c; var i; for (i in this._appboxes) { c = this._appboxes[i]; if (c && c.hd) { if (c.isvariable) { variable = c; } else { availableht -= (c.offsetHeight+5); } } steps++; } if (variable) { f(variable, availableht); } /* if (nChildren == 1) { f(box.childNodes[0],bounds.h); } else { var divisions = []; var htremaining = bounds.h; var nFixed = 0; for (var i = 0; i < nChildren; i++) { var c = box.childNodes[i]; var d = {max:false, min: false, ht:0}; if (c.minHeight) { d.min = c.minHeight; d.ht = c.minHeight; htremaining -= c.minHeight; } if (c.maxHeight) { d.max = c.maxHeight; } if (c.fixedHeight) { d.ht = c.fixedHeight; d.fixed = c.fixedHeight; htremaining -= c.fixedHeight; nFixed++; } divisions[i] = d; } while(htremaining > 1) { var s = htremaining/(nChildren-nFixed); var n = nChildren - nFixed; for(var i = 0; i < nChildren; i++) { var c = box.childNodes[i]; var d = divisions[i]; if(d.fixed) { //f(c, d.ht); htremaining-=d.ht; } else if (d.max && d.ht + s > d.max) { //f(c,d.max); d.ht = d.max; n--; s += (s-d.max)/n; htremaining-=d.max; nFixed++; d.fixed = d.max; } else { n--; d.ht += s; //f(c, d.ht + s); htremaining-=d.ht; } } } if(htremaining > 0) { divisions[nChildren-1] += 1; } for (var i = 0; i < nChildren; i++) { f(box.childNodes[i],divisions[i].ht); } }*/ }; FIRSTCLASS.ui.NavBar = function() { var that = this; var domElement = $('fcNavBar'); var picture = $('fcNavBarPicture'); var unread = $('fcNavBarPictureFlag'); var title = $('fcNavTitle'); var bottomText = $('fcNavBarBottomText'); var navContentPane = $('fcNavBarContentPane'); that.setProfileItem = function(pclass, html) { FIRSTCLASS.ui.Dom.getChildByClassName(pclass, domElement).innerHTML = html; }; that.setSmallUserProfilePicture = function(height,cid,name,addDateParam) { var ht = height || 67; picture.height = ht; FIRSTCLASS.util.User.setSmallProfPicUrlByCid(picture,cid,addDateParam); picture.setAttribute('fcattrs', name); }; that.setLargeUserProfilePicture = function(height,cid,addDateParam) { var ht = height || 180; picture.height = ht; FIRSTCLASS.util.User.setLargeProfPicUrlByCid(picture,cid,addDateParam, false); }; that.setProfilePicture = function(uri, height, fcid) { picture.src = uri; var ht = height || 67; picture.height = ht; if (fcid) { picture.setAttribute('fcid', fcid); } else { picture.setAttribute('fcid', ''); } }; that.setProfileUnread = function(count, uri) { YAHOO.util.Dom.removeClass(unread, 'fcIconFlagNone'); YAHOO.util.Dom.removeClass(unread, 'fcIconFlag'); YAHOO.util.Dom.removeClass(unread, 'fcIconFlagWide1'); YAHOO.util.Dom.removeClass(unread, 'fcIconFlagWide2'); if (uri) { unread.setAttribute('fcid', 'unread'); unread.setAttribute('fcattrs', uri); } else { unread.setAttribute('fcid', ''); unread.setAttribute('fcattrs', ''); } if (count == 0) { YAHOO.util.Dom.addClass(unread, 'fcIconFlagNone'); } else if (count < 10) { YAHOO.util.Dom.addClass(unread, 'fcIconFlag'); unread.innerHTML = count; } else if (count < 100) { YAHOO.util.Dom.addClass(unread, 'fcIconFlagWide1'); unread.innerHTML = count; } else if (count < 1000) { YAHOO.util.Dom.addClass(unread, 'fcIconFlagWide2'); unread.innerHTML = count; } else { YAHOO.util.Dom.addClass(unread, 'fcIconFlagWide2'); unread.innerHTML = "lots"; } }; that.setTitleAndLink = function (user) { YAHOO.util.Dom.setStyle(title, "cursor", "pointer"); // YAHOO.util.Event.purgeElement(title, true); title.innerHTML = "" + user.name+""; /* that.setTitle(user.name);*/ that.setProfileLink(user); }; that.setTitle = function(name) { YAHOO.util.Dom.setStyle(title, "cursor", "default"); title.innerHTML = name; /*title.removeAttributeNode('fcid'); title.removeAttributeNode('fcattrs'); title.removeAttributeNode('uid');*/ }; that.getTitle = function() { return title.innerHTML; }; that.setProfileLink = function (currentUser) { YAHOO.util.Dom.setStyle(title, "cursor", "pointer"); YAHOO.util.Dom.setStyle(picture, "cursor", "pointer"); title.firstChild.setAttribute('fcid', 'user'); title.firstChild.setAttribute('fcattrs', currentUser.name); title.firstChild.setAttribute('uid', currentUser.cid); } that.setProfileStatus = function(status, listener) { // FIXME: much more complicated than this to get this working var blankText = FIRSTCLASS.locale.desktop.emptystatus; if (typeof status == "string") { if (status == "") { status = blankText; } var html = []; html.push(''); html.push(''); html.push(''); html.push(''); html.push(''); html.push(''); html.push('
'); html.push(''); html.push('
'); bottomText.innerHTML = html.join("");//""; var curstatus = FIRSTCLASS.ui.Dom.getChildByClassName('fcStatusText', bottomText); var table = FIRSTCLASS.ui.Dom.getChildByClassName('fcTextIn', bottomText); 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) { // enter listener.saveProfileStatus(curstatus.value); curstatus.blur(); } YAHOO.util.Event.stopPropagation(evt); }); YAHOO.util.Event.addListener(curstatus, "blur", function(evt) { if (curstatus.value == "") { listener.saveProfileStatus(curstatus.value); curstatus.value = blankText; } else if (curstatus.value != FIRSTCLASS.util.BuddyList._message) { listener.saveProfileStatus(curstatus.value); } YAHOO.util.Dom.removeClass(table, "focussed"); }); YAHOO.util.Event.addListener(curstatus, "focus", function(evt) { if (curstatus.value == blankText) { curstatus.value = ""; } else { curstatus.select(); } YAHOO.util.Dom.addClass(table, "focussed"); }); } } else { bottomText.innerHTML = ""; } }; that.setBottomText = function(html) { bottomText.innerHTML = html; }; that.getProfileStatus = function() { var curstatus = FIRSTCLASS.ui.Dom.getChildByClassName('fcStatusText', domElement); if (curstatus) { return curstatus.value; } else { return ""; } }; that.setContentPane = function(contents) { var cp = navContentPane; if ($('fcNavBarOverrideContentBox')) { cp = $('fcNavBarOverrideContentBox'); } FIRSTCLASS.ui.Dom.replaceContentsWithElement(cp, contents); YAHOO.util.Dom.setStyle(cp, "display", ""); if (FIRSTCLASS.session.getActiveApplication().resizeEvent) { FIRSTCLASS.session.getActiveApplication().resizeEvent(); } }; that.clearContentPane = function() { var cp = navContentPane; var override = false; if ($('fcNavBarOverrideContentBox')) { cp = $('fcNavBarOverrideContentBox'); override = true; } YAHOO.util.Dom.setStyle(cp, "display", "none"); FIRSTCLASS.ui.Dom.clearElementChildren(cp); if (FIRSTCLASS.session.getActiveApplication().resizeEvent) { FIRSTCLASS.session.getActiveApplication().resizeEvent(); } if (override) { var div = document.createElement("div"); div.appendChild(cp); div.innerHTML = ""; } }; that.hide = function() { YAHOO.util.Dom.setStyle(domElement.parentNode, "display", "none"); }; that.show = function() { YAHOO.util.Dom.setStyle(domElement.parentNode, "display", ""); }; that.updateShoutBox = function(shouts) { if (typeof shouts == "string") { shouts = [ { parsedDate: new Date(), message: shouts, fontsize: "1.1em" } ]; } if (shouts.length && FIRSTCLASS.ui.navBar) { var shout = shouts[shouts.length-1]; if (!shout.fontsize) { shout.fontsize = "2em"; } var date = FIRSTCLASS.lang.fcTimeToDate(shout.ts); if (shout.parsedDate) { date = shout.parsedDate; } var hrs = date.getHours()%12; if (hrs == 0) { hrs = 12; } var dstr = hrs+":"+date.getMinutes()+((date.getHours()>=12)?' pm':' am'); var html = ["
", "
at ", dstr, ", the administrator said:
", shout.message,"
"]; var el = document.createElement("div"); el.innerHTML = html.join(""); var contentPane = FIRSTCLASS.ui.widgets.buildContentBox(el, 'fcWhiteContentBox'); el = document.createElement("div"); el.appendChild(contentPane); YAHOO.util.Dom.setStyle(el, 'padding', '10px'); FIRSTCLASS.ui.navBar.setContentPane(el); } }; }; FIRSTCLASS.ui.LeftSideBar = function(domElement) { var that = new FIRSTCLASS.ui.sideBar(domElement, true); that.getSearch = function() { }; return that; }; // NOTE - text only for now; expand later to get range object FIRSTCLASS.ui.getSelection = function(fake) { var sel; if (window.getSelection) { sel = window.getSelection(); } else if (document.selection) { sel = document.selection.createRange(); } if (fake) { var fk = {length:0} if (sel) { fk.length = 1; } return fk; } if ((YAHOO.env.ua.gecko || YAHOO.env.ua.webkit) && sel && sel.rangeCount > 0) { var r = sel.getRangeAt(0).cloneContents(); var s = document.createElement("div"); while (r.childNodes.length) { s.appendChild(r.childNodes[0]); } sel = s.innerHTML; s.innerHTML = ""; s = false; } else if (YAHOO.env.ua.ie) { sel = sel.htmlText; } return "" + sel; }; // handling for WebDAV plugin FIRSTCLASS.ui.webdav = { osPlatform: function() { var platform = "other"; var ua = navigator.userAgent.toLowerCase(); if ((ua.indexOf("win") >= 0) || (ua.indexOf("32bit") >= 0)) { platform = "windows"; } else if (ua.indexOf("mac") >= 0) { platform = "mac"; } return platform; }, hasOfficePlugin: function() { var found = false; if (FIRSTCLASS.ui.webdav.osPlatform() == "windows") { if (YAHOO.env.ua.ie) { try { var axo = new ActiveXObject("Bluefield.BFCtrl.1"); found = true; } catch(e) { } } else if (YAHOO.env.ua.gecko) { var type = ""; for (var i = 0; i < navigator.mimeTypes.length; i++) { type = navigator.mimeTypes[i].type.toLowerCase(); if (type == "application/x-otbluefield") { if (navigator.mimeTypes[i].enabledPlugin != null) { found = true; } break; } } } } return found; }, loadOfficePlugin: function(domEl) { var html = []; html.push(""); domEl.innerHTML = html.join(""); }, pluginLoaded: function() { if (typeof URLLauncher != "undefined") { return true; } else { var plugin= null; if (window.document.URLLauncher) { plugin = window.document.URLLauncher; } if (navigator.appName.indexOf("Microsoft Internet")==-1 && document.embeds && document.embeds.URLLauncher) { plugin = document.embeds.URLLauncher; } else { plugin = document.getElementById("URLLauncher"); } if (plugin !== null) { return true; } } return false; }, installPlugin: function(domEl) { // put up dialog var doInstall = function() { if (YAHOO.env.ua.gecko) { var params = {}; params[FIRSTCLASS.locale.community.docs.plugin.FFName] = { URL: '/bluefield.templates/firstclass/resources/browserplugins/bfplug.xpi', Hash: 'sha1:80c10ec05994bcb5ad673df34f9444889ff768b4', toString: function () { return this.URL; } }; InstallTrigger.install(params); } else if (YAHOO.env.ua.ie) { FIRSTCLASS.ui.webdav.loadOfficePlugin(domEl); } instDlg.destroy(); }; var doCancel = function() { instDlg.destroy(); }; var instDlg = new YAHOO.widget.Dialog("dlg", { width: '400px', fixedcenter: true, postmethod: 'manual', visible: false, draggable: false, buttons: [ { text: FIRSTCLASS.locale.community.docs.plugin.cancel, handler: doCancel }, { text: FIRSTCLASS.locale.community.docs.plugin.install, handler: doInstall, isDefault: true } ] }); instDlg.setHeader(FIRSTCLASS.locale.community.docs.plugin.header); instDlg.setBody(FIRSTCLASS.locale.community.docs.plugin.message); instDlg.render(document.body); instDlg.show(); }, edit: function(domEl, row, ds) { if (FIRSTCLASS.ui.webdav.hasOfficePlugin()) { if (!FIRSTCLASS.ui.webdav.pluginLoaded()) { FIRSTCLASS.ui.webdav.loadOfficePlugin(domEl); } if (row && FIRSTCLASS.ui.webdav.pluginLoaded()) { var url = ds.getItemUrl(row, true, true, true); url = FIRSTCLASS.lang.removeSlashUrl(url.slice(0,url.lastIndexOf("?"))); if (url) { if (typeof URLLauncher != "undefined") { URLLauncher.dourl(url); } else { var plugin= null; if (window.document.URLLauncher) { plugin = window.document.URLLauncher; } if (navigator.appName.indexOf("Microsoft Internet")==-1 && document.embeds && document.embeds.URLLauncher) { plugin = document.embeds.URLLauncher; } else { plugin = document.getElementById("URLLauncher"); } if (plugin !== null) { plugin.dourl(url); } } } } } else { FIRSTCLASS.ui.webdav.installPlugin(domEl); } } }; FIRSTCLASS.util.Date = { getDayString: function(date) { return FIRSTCLASS.locale.Date.getDayString(date); }, getMonthString: function(date) { return FIRSTCLASS.locale.Date.getMonthString(date); }, getFriendlyDateString: function(datein) { var date = datein; if (typeof datein == "string") { date = new Date(Date.parse(datein)); } else if (typeof datein == "number") { date = new Date(); date.setTime(datein*1000); } var now = new Date(); var ADAYOFMILLISECONDS = 24*60*60*1000; var tomorrow = new Date(now.getTime() + ADAYOFMILLISECONDS); var yesterday = new Date(now.getTime() - ADAYOFMILLISECONDS); // today if (now.getMonth() == date.getMonth() && now.getYear() == date.getYear() && now.getDate() == date.getDate()) { return FIRSTCLASS.locale.Date.today; } else if (yesterday.getMonth() == date.getMonth() && yesterday.getYear() == date.getYear() && date.getDate() == yesterday.getDate()) { return FIRSTCLASS.locale.Date.yesterday; } else if (tomorrow.getMonth() == date.getMonth() && tomorrow.getYear() == date.getYear() && date.getDate() == tomorrow.getDate()) { return FIRSTCLASS.locale.Date.tomorrow; } // days of week var daystr = FIRSTCLASS.util.Date.getDayString(date); if (now.getDate() > date.getDate() && now.getMonth() == date.getMonth() && now.getDay() > date.getDay() && now.getDate()-now.getDay() == date.getDate() - date.getDay()) { return daystr; } else { var str = /*daystr + ", " +*/ FIRSTCLASS.util.Date.getMonthString(date) + " " + FIRSTCLASS.locale.Date.getFriendlyDay(date); if ( date.getYear() != now.getYear() ) { str += ", " + date.getFullYear(); } return str; } }, getFriendlyShortDateString: function(datein) { var date = datein; if (typeof datein == "string") { date = new Date(Date.parse(datein)); } else if (typeof datein == "number") { date = new Date(); date.setTime(datein*1000); } var now = new Date(); var ADAYOFMILLISECONDS = 24*60*60*1000; var tomorrow = new Date(now.getTime() + ADAYOFMILLISECONDS); var yesterday = new Date(now.getTime() - ADAYOFMILLISECONDS); // today if (now.getMonth() == date.getMonth() && now.getYear() == date.getYear() && now.getDate() == date.getDate()) { return FIRSTCLASS.locale.Date.today; } else if (yesterday.getMonth() == date.getMonth() && yesterday.getYear() == date.getYear() && date.getDate() == yesterday.getDate()) { return FIRSTCLASS.locale.Date.yesterday; } else if (tomorrow.getMonth() == date.getMonth() && tomorrow.getYear() == date.getYear() && date.getDate() == tomorrow.getDate()) { return FIRSTCLASS.locale.Date.tomorrow; } // days of week var daystr = FIRSTCLASS.util.Date.getDayString(date); if (now.getDate() > date.getDate() && now.getMonth() == date.getMonth() && now.getDay() > date.getDay() && now.getDate()-now.getDay() == date.getDate() - date.getDay()) { return daystr; } else { var str = FIRSTCLASS.util.Date.getMonthString(date).substr(0,3) + ". " + date.getDate(); if ( date.getYear() != now.getYear() ) { str += ", " + date.getFullYear(); } return str; } }, getFriendlyTimeString: function(datein) { var date = datein; if (typeof datein == "string") { date = new Date(Date.parse(datein)); } else if (typeof datein == "number") { date = new Date(); date.setTime(datein*1000); } var now = new Date(); var str = ""; if (now.getMonth() == date.getMonth() && now.getYear() == date.getYear() && now.getDate() == date.getDate()) { var diff = (now.getTime() - date.getTime())/1000; if (diff <= 3600) { // within the past hour if (diff <= 60) { str = FIRSTCLASS.locale.Date.subminute; } else if (diff <= 600) { str = FIRSTCLASS.locale.Date.aboutminutes.replace("$minutes$", Math.ceil(diff/60)); } else if (diff <= 1500 || (diff >= 2100 && diff <= 3400)) { str = FIRSTCLASS.locale.Date.aboutminutes.replace("$minutes$", Math.ceil(diff/60)); } else if (diff <= 2100) { str = FIRSTCLASS.locale.Date.halfhour; } else { str = FIRSTCLASS.locale.Date.hour; } } } if (str=="") { str = FIRSTCLASS.locale.Date.at + " " + (((date.getHours() %12)== 0)?"12":(date.getHours() % 12)) + ":" + ((date.getMinutes()< 10)?"0":"") + date.getMinutes() + ((date.getHours()>=12)?"PM":"AM"); } return str; }, getFriendlyDateTimeString: function(datein) { var str = FIRSTCLASS.util.Date.getFriendlyDateString(datein) + ", " + FIRSTCLASS.util.Date.getFriendlyTimeString(datein); return str; } }; FIRSTCLASS.util.Display = { getFileSizeString: function(fileBytes) { var b = fileBytes; var s = ""; if (b >= 1048576) { // meg if (b >= 10485760) { s = (b/(1048576)).toFixed(0) + " MB"; } else { s = (b/(1048576)).toFixed(1) + " MB"; } } else { if (b >= 1024) { // k s = (b/1024).toFixed(0) + " kB"; } else { s = b.toString() + " B"; }; }; return s; }, getIconID: function(fileName) { var ext = "" + fileName; ext = ext.slice(ext.lastIndexOf(".") + 1).toLowerCase(); var iconID = 9630; if (ext) { iconID = FIRSTCLASS.fileTypeIcons[ext]; } if (iconID === undefined) { iconID = 9630; } return iconID; }, // check if our office plugin can handle a file/ext isEditableOfficeFile: function(fileName) { var isOffice = false; var iconID = FIRSTCLASS.util.Display.getIconID(fileName); switch (iconID) { case 9620: case 9621: case 9622: isOffice = true; } return isOffice; } }; if (!FIRSTCLASS.session) { FIRSTCLASS.session = {}; } if (!FIRSTCLASS.session.setActiveObject) { FIRSTCLASS.session.setActiveObject = function(uri) { FIRSTCLASS.session._activeObject = uri; }; FIRSTCLASS.session.getActiveObject = function(){ return FIRSTCLASS.session._activeObject; }; FIRSTCLASS.session.setActiveApplication = function(app,name) { FIRSTCLASS.session._activeApplication = app; FIRSTCLASS.session._activeAppName = name || ""; if ((FIRSTCLASS.session._activeAppName == "feed") || (FIRSTCLASS.session._activeAppName == "feed")) FIRSTCLASS.session._activeCommunity = app; }; FIRSTCLASS.session.getActiveApplication = function() { return FIRSTCLASS.session._activeApplication; }; FIRSTCLASS.session.getActiveApplicationName = function() { return FIRSTCLASS.session._activeAppName; }; FIRSTCLASS.session.handleUrl = function (handler, target) { var currObj = handler.decomposeUrl(FIRSTCLASS.session._activeObject); var handled = false; var tComm = null; if (target.path.length > 1) tComm = target.path[1]; /* if url is in current community, pass it to that community */ if ((currObj.path.length > 1) && tComm) { if (currObj.path[1].toUpperCase() == tComm.toUpperCase()) { FIRSTCLASS.session._activeCommunity.navToItemUrl(handler, target); handled = true; }; }; /* if url is in a community on this system, open that community and auto load the item */ var dds = FIRSTCLASS.session.desktop._dataSource; if (dds) { var rows = dds.query("name", tComm, true); if (rows.length < 0) { alert ("Got one!"); } } }; } FIRSTCLASS.session.RuntimeCSS = { _indexes: [], init: function() { if (!this.element) { this.element = document.createElement("STYLE"); this.element.type="text/css"; this.element.id = "fcGeneratedCSS"; this._parent = document.getElementsByTagName("head").item(0); this._cacheParent = document.createElement("div"); this._parent.appendChild(this.element); } }, removeRulesFromDom: function() { if (this._cacheParent && YAHOO.env.ua.ie) { this._cacheParent.appendChild(this.element); } }, addRulesToDom: function() { if (this._parent && YAHOO.env.ua.ie) { this._parent.appendChild(this.element); } }, updateRule: function(selector, newrule) { this.init(); var sheet = this.element.styleSheet; if (!sheet) { sheet = this.element.sheet; } var index = false; if (this._indexes[selector]) { index = this._indexes[selector]; } if (YAHOO.env.ua.ie) { if (!index) { index = sheet.rules.length; } else { sheet.removeRule(index); } sheet.addRule(selector, newrule, index); } else { if (!index) { index = sheet.cssRules.length; sheet.insertRule(selector + " { " + newrule + " }", index); } else { if (sheet.cssRules) { sheet.cssRules[index].style.cssText = newrule; } else if (sheet.rules) { sheet.rules[index].style.cssText = newrule; } else { sheet.deleteRule(index); } } } this._indexes[selector] = index; return index; } }; FIRSTCLASS.session.UserStatuses = { statuses: [], images: ["/firstclass/images/offline.png", "/firstclass/images/online.png"], init: function() { if (!this._initialized) { // this._interval = window.setInterval(this.onInterval, 500); this._initialized = true; } }, updateStatus: function(cid, status) { this.init(); /* status is [0,1] offline/online */ if (typeof cid == "number") { cid = "CID" + cid; } var stat = this.statuses[cid]; var oldstatus = 0; if (!stat) { stat = {status:status, cid: cid}; this.statuses[cid] = stat; } else { oldstatus = stat.status; stat.status = status; stat.cid = cid; } if (oldstatus != status) { stat.dirty = true; this._dirty = true; } }, generateCSS: function() { if (this._dirty) { var stat = false; var rules; FIRSTCLASS.session.RuntimeCSS.removeRulesFromDom(); for (var i in this.statuses) { stat = this.statuses[i]; if (stat.dirty) { rules = ["background-image: url("+FIRSTCLASS.session.templatebase + this.images[stat.status] + ");"]; if (stat.status == 0) { rules.push("width:0px;height:0px;"); } else { rules.push("width:7px;height:7px;"); } stat.index = FIRSTCLASS.session.RuntimeCSS.updateRule(".fcUser" + stat.cid + " .statusicon", rules.join("")); stat.dirty = false; } } FIRSTCLASS.session.RuntimeCSS.addRulesToDom(); this._dirty = false; } }, onInterval: function() { FIRSTCLASS.session.UserStatuses.generateCSS(); } }; FIRSTCLASS.events = { processEvent: function(evt, type) { var target = YAHOO.util.Event.getTarget(evt); var rv = []; if (target) { var attr = target.getAttribute("fcid"); var attr2 = target.getAttribute("fcattrs"); var events = target.getAttribute('fcevents'); if (events) { events = events.split(","); } if (attr) { var types = attr.split(","); for (var i in types) { attr = types[i]; rv.push({fcid: attr, fcattrs: attr2, target: target, fcevents: events}); } } else { var depth = 0; var maxdepth = 100; var tmp = target; while (depth < maxdepth && tmp && (typeof tmp.getAttribute == "function" || typeof tmp.getAttribute == "object") ) { if (tmp.getAttribute("fcid")) { target = tmp; break; } tmp = tmp.parentNode; depth++; } var attr = target.getAttribute("fcid"); var attr2 = target.getAttribute("fcattrs"); var events = target.getAttribute('fcevents'); if (events) { events = events.split(','); } if (attr) { var types = attr.split(","); for (var i in types) { attr = types[i]; rv.push({fcid: attr, fcattrs: attr2, target: target, wasRecursive: true, fcevents: events}); } } } } return rv; }, eventHandlers: { click: { search: function(event, fcevent) { FIRSTCLASS.search({key:fcevent.fcattrs}); }, tag: function(event, fcevent) { var tag = fcevent.fcattrs; var mode = fcevent.target.getAttribute("mode"); switch (mode) { case "tag": FIRSTCLASS.apps.Workflows.Tags.addTag(tag); break; case "delete": FIRSTCLASS.apps.Workflows.Tags.removeTag(tag); break; case "search": FIRSTCLASS.search({key:tag}); break; default: /* unhandled mode, or no mode at all - do nothing */ } }, community: function(event, fcevent) { var uri = FIRSTCLASS.lang.removeSlashUrl(fcevent.fcattrs); var rows = FIRSTCLASS.apps.Desktop.instance._dataSource.query("uri", uri, true, function(key, search) { var newkey = FIRSTCLASS.lang.removeSlashUrl(key); var newsearch = FIRSTCLASS.lang.removeSlashUrl(search); return (newkey.indexOf(newsearch) >= 0); }); if (rows.length) { var row = rows[0][1]; var params = { title: row.name, unread:row.status.unread, icon: row.icon.uri}; if (row.lconfcid.length > 0) { params.lconfcid = parseInt(row.lconfcid); } FIRSTCLASS.loadApplication(FIRSTCLASS.session.baseURL + fcevent.fcattrs, row.typedef.objtype, row.typedef.subtype, params); } }, user: function(event, fcevent) { if (FIRSTCLASS.ui.MiniProfile.showTimeout) { window.clearTimeout(FIRSTCLASS.ui.MiniProfile.showTimeout); FIRSTCLASS.ui.MiniProfile.showTimeout = false; } FIRSTCLASS.ui.MiniProfile.hideBoxNow(); var uidString = fcevent.target.getAttribute("uid"); var uid = isNaN(uidString) ? null : parseInt(uidString); var url = ""; var name = fcevent.fcattrs; var config = {name: name,editProfile:0} if (!uid) { url = FIRSTCLASS.util.User.getProfileUrlByName(name); } else { var cid = "CID"+uid; url = FIRSTCLASS.util.User.getProfileUrlByCid(cid); config.cid = cid; config.uid = uid; } var isSafe = true; if (FIRSTCLASS.session.getActiveApplication() && FIRSTCLASS.session.getActiveApplication().isSafeToNavigate) { isSafe = FIRSTCLASS.session.getActiveApplication().isSafeToNavigate(); if (!isSafe) { isSafe = confirm(FIRSTCLASS.locale.desktop.navaway.prefix + "\n\n" + FIRSTCLASS.locale.desktop.navaway.editing + "\n\n" + FIRSTCLASS.locale.desktop.navaway.suffix); if (isSafe && FIRSTCLASS.session.getActiveApplication().overrideSafeToNavigate) { FIRSTCLASS.session.getActiveApplication().overrideSafeToNavigate(); } } } if (isSafe) { FIRSTCLASS.session._nextNavigationIsSafe = true; FIRSTCLASS.loadApplication(url, FIRSTCLASS.objTypes.folder, FIRSTCLASS.subTypes.profile, config); } }, navigation: function(event, fcevent) { /*var isSafe = true; if (FIRSTCLASS.session.getActiveApplication() && FIRSTCLASS.session.getActiveApplication().isSafeToNavigate) { isSafe = FIRSTCLASS.session.getActiveApplication().isSafeToNavigate(); if (!isSafe) { isSafe = confirm(FIRSTCLASS.locale.desktop.navaway.prefix + "\n\n" + FIRSTCLASS.locale.desktop.navaway.editing + "\n\n" + FIRSTCLASS.locale.desktop.navaway.suffix); if (isSafe && FIRSTCLASS.session.getActiveApplication().overrideSafeToNavigate) { FIRSTCLASS.session.getActiveApplication().overrideSafeToNavigate(); } } } if (!isSafe) { YAHOO.util.Event.stopEvent(event); return true; } else */{ return false; } }, account: function(event, fcevent) { FIRSTCLASS.loadApplication(FIRSTCLASS.session.baseURL + '__MemForm?FormID=139',-100,0); }, newcommunity: function(event,fcevent) { FIRSTCLASS.loadApplication(FIRSTCLASS.session.baseURL, -103); }, clear: function(event, fcevent) { if (fcevent.target) { fcevent.target.innerHTML = ""; } } }, mousemove: { user: function(event,fcevent) { if (FIRSTCLASS.ui.MiniProfile.mouseInside) FIRSTCLASS.ui.MiniProfile.resetOnMove(event,fcevent); } }, mouseover: { user: function(event, fcevent) { if (fcevent.target.getAttribute("nohover")) { FIRSTCLASS.ui.MiniProfile.show(); return; } FIRSTCLASS.ui.MiniProfile.mouseInside = true; FIRSTCLASS.ui.MiniProfile.mouseHasLeft = false; var target = fcevent.target; if (!fcevent.wasRecursive) { var depth = 0; var maxdepth = 100; var tmp = target; while (depth < maxdepth && tmp) { tmp = tmp.parentNode; if (tmp && (typeof tmp.getAttribute != "undefined") && tmp.getAttribute("fcid") == "user") { target = tmp; break; } depth++; } } var _uid = 0; var uidString = target.getAttribute("uid"); if (typeof uidString == "string") { if (uidString.indexOf("CID") == 0) uidString = uidString.substring(3); if (!isNaN(uidString)) _uid = parseInt(uidString); } else if (typeof uidString == "number") _uid = uidString; var _name = (typeof fcevent.fcattrs == 'undefined' ? "" : fcevent.fcattrs); if ((_name == "") && (_uid==0)) return; var config = {name: _name, uid : _uid}; if (_uid != 0) document.getElementById('hiddenprofpic').src = FIRSTCLASS.util.User.getLargeProfPicUrlByCid(_uid); else { document.getElementById('hiddenprofpic').src = FIRSTCLASS.util.User.getLargeProfPicUrlByName(_name); //alert("is zero 1st"); } FIRSTCLASS.ui.MiniProfile.dispatchShow(target, config); }, ihover: function(event, fcevent) { FIRSTCLASS.ui.hover.apply(fcevent.target, 'ihover'); } }, mouseout: { user: function(event, fcevent) { FIRSTCLASS.ui.MiniProfile.mouseInside = false; FIRSTCLASS.ui.MiniProfile.mouseout(fcevent) }, ihover: function(event, fcevent) { FIRSTCLASS.ui.hover.remove(fcevent.target, 'ihover'); } }, global: { resizeEvent: function(evt) { FIRSTCLASS.ui.Dom.updateViewportBounds(); /*if (FIRSTCLASS.session.getActiveApplication() && FIRSTCLASS.session.getActiveApplication().resizeEvent && FIRSTCLASS.session.getActiveApplication().resizeEvent(evt)) { // handled event //return false; }*/ return false; } } }, doubleClickThreshold: 500, preventDoubleClicks: function(evt, fcid) { var lastevent = this.lastevent; var lastfcid = this.lastfcid; var lasteventtime = this.lasttime; var time = new Date(); var rv = false; if (lasteventtime && lastfcid == fcid) { var diff = time.getTime() - lasteventtime.getTime(); rv = diff <= this.doubleClickThreshold; } this.lastevent = evt; this.lasttime = time; this.lastfcid = fcid; return rv; }, handler: function(evt) { var evts = this.processEvent(evt); var rv = false; if (evts && evts.length) { var e; for (var i in evts) { e = evts[i]; if (FIRSTCLASS.events._overrideHandler && FIRSTCLASS.events._overrideHandler.handleEvent(evt, e)) { YAHOO.util.Event.stopEvent(evt); return false; } if (evt.type == "click" && this.preventDoubleClicks(evt, e.fcid)) { rv = true; } else if (FIRSTCLASS.session.getActiveApplication() && FIRSTCLASS.session.getActiveApplication().handleEvent && FIRSTCLASS.session.getActiveApplication().handleEvent(evt, e)) { YAHOO.util.Event.stopEvent(evt); // handled event return false; } else { if (e.fcevents) { var handle = false; for (var i in e.fcevents) { if (evt.type == e.fcevents[i]) { handle = true; } } if (!handle) { continue; } } var handlers = this.eventHandlers[evt.type]; if (handlers) { var h = handlers[e.fcid]; if (h) { if (typeof h == 'function') { rv = h(evt, e); if (typeof rv == "undefined") { rv = true; } } else { alert("Non-function member in event handler list.") } } } } } } return !rv; }, registerOverrideHandler: function(object) { FIRSTCLASS.events._overrideHandler = object; }, register: function() { var that = this; var func = function(evt) { return that.handler(evt); }; YAHOO.util.Event.addListener(document.body, 'click', func); YAHOO.util.Event.addListener(document.body, 'dblclick', func); YAHOO.util.Event.addListener(document.body, 'mouseup', func); YAHOO.util.Event.addListener(document.body, 'mousedown', func); YAHOO.util.Event.addListener(document.body, 'mouseover', func); YAHOO.util.Event.addListener(document.body, 'mouseout', func); YAHOO.util.Event.addListener(document.body, 'mousemove', func); YAHOO.util.Event.addListener(window, "resize", FIRSTCLASS.events.eventHandlers.global.resizeEvent); } }; /** * The FIRSTCLASS global namespace object. If FIRSTCLASS is already defined, the * existing FIRSTCLASS object will not be overwritten so that defined * namespaces and variables are preserved. * @class FIRSTCLASS * @static */ /** * register FirstClass classes with the YUI Loader so we can load them on the fly * * @method registerWithYUI * @param {Object} loader (required) an instance of the YUI Loader to register with * @static */ FIRSTCLASS.registerWithYUI = function() { /* template for adding a new module */ /* FIRSTCLASS._loader.addModule({ name: "fc", type: "js", fullpath: "/firstclass//.js", requires: ['fcbase', '...'] // if any dependencies exist }); must be accompanied by a matching YAHOO.register on the last line of your .js file as shown in template/template.js */ var added = FIRSTCLASS._loader.addModule({ name: "fcDataSource", type: "js", fullpath: FIRSTCLASS.session.templatebase + "/firstclass/util/DataSource.js", requires: ['yahoo', 'dom', 'event', "connection", 'logger', "json"] }); added = FIRSTCLASS._loader.addModule({ name: "fcThread", type: "js", fullpath: FIRSTCLASS.session.templatebase + "/firstclass/layout/Thread.js", requires: ['fcDataSource'] }); added = FIRSTCLASS._loader.addModule({ name: "fcListView", type: "js", fullpath: FIRSTCLASS.session.templatebase + "/firstclass/layout/ListView.js", requires: ['fcDataSource', 'button', 'fcThread', 'dragdrop','resize'] }); added = FIRSTCLASS._loader.addModule({ name: "fcFeed", type: "js", fullpath: FIRSTCLASS.session.templatebase + "/firstclass/layout/Feed.js", requires: ['fcListView', 'menu'] }); /* Apps section, one entry per Application (two if there's css) */ added = FIRSTCLASS._loader.addModule({ name: "fcHistory", type: "js", fullpath: FIRSTCLASS.session.templatebase + "/firstclass/apps/history.js", requires: ['fcListView'] }); added = FIRSTCLASS._loader.addModule({ name: "fcDocuments", type: "js", fullpath: FIRSTCLASS.session.templatebase + "/firstclass/apps/Documents.js", requires: ['fcListView', 'fcHistory','datatable'] }); added = FIRSTCLASS._loader.addModule({ name: "fcDiscussion", type: "js", fullpath: FIRSTCLASS.session.templatebase + "/firstclass/apps/Community.js", requires: ['fcListView', 'tabview'/*, 'slider'*/] }); added = FIRSTCLASS._loader.addModule({ name: "fcWiki", type: "js", fullpath: FIRSTCLASS.session.templatebase + "/firstclass/apps/Wiki.js", requires: ['fcListView', 'fcHistory'] }); added = FIRSTCLASS._loader.addModule({ name: "fcCalendar", type: "js", fullpath: FIRSTCLASS.session.templatebase + "/firstclass/apps/Calendar.js", requires: ['fcListView', 'datatable'] }); added = FIRSTCLASS._loader.addModule({ name: "fcTasks", type: "js", fullpath: FIRSTCLASS.session.templatebase + "/firstclass/apps/Tasks.js", requires: ['fcListView', 'datatable'] }); added = FIRSTCLASS._loader.addModule({ name: "fcFormDialog", type: "js", fullpath: FIRSTCLASS.session.templatebase + "/firstclass/apps/Account.js", requires: ['yahoo', 'dom', 'event', 'connection', /*'logger',*/ 'container','containercore','fcFormUtils','button'] }); added = FIRSTCLASS._loader.addModule({ name: "fcWorkflows", type: "js", fullpath: FIRSTCLASS.session.templatebase + "/firstclass/apps/Workflows.js", requires: ['fcFormDialog', 'autocomplete'] }); added = FIRSTCLASS._loader.addModule({ name: "fcIntegration", type: "js", fullpath: FIRSTCLASS.session.templatebase + "/firstclass/apps/Integration.js", requires: ['fcFormDialog',"fcWorkflows", 'treeview'] }); added = FIRSTCLASS._loader.addModule({ name: "fcFormUtils", type: "js", fullpath: FIRSTCLASS.session.templatebase + "/firstclass/util/Form.js", requires: ['yahoo', 'dom', 'event', 'connection', 'container','containercore','button', 'editor', 'autocomplete'] }); added = FIRSTCLASS._loader.addModule({ name: "fcCommunity", type: "js", fullpath: FIRSTCLASS.session.templatebase + "/firstclass/apps/Community.js", requires: ['fcListView', 'tabview', 'fcFeed', /*'fcMembers', */'fcFormDialog', 'fcFormUtils', /*'fcDiscussion',*/ 'fcIntegration'] }); added = FIRSTCLASS._loader.addModule({ name: "fcSearch", type: "js", fullpath: FIRSTCLASS.session.templatebase + "/firstclass/apps/Search.js", requires: ['fcListView', 'fcFeed', 'paginator', 'tabview', 'fcIntegration'] }); added = FIRSTCLASS._loader.addModule({ name: "fcMusic", type: "js", fullpath: FIRSTCLASS.session.templatebase + "/firstclass/apps/Music.js", requires: ['fcListView','datasource','datatable'] }); added = FIRSTCLASS._loader.addModule({ name: "fcBlog", type: "js", fullpath: FIRSTCLASS.session.templatebase + "/firstclass/apps/blog.js", requires: ['fcListView', 'fcFormUtils', 'fcWorkflows'] }); added = FIRSTCLASS._loader.addModule({ name: "fcBlogFeed", type: "js", fullpath: FIRSTCLASS.session.templatebase + "/firstclass/layout/blogfeed.js", requires: ['fcListView', 'tabview', /*'slider',*/ 'fcBlog'] }); added = FIRSTCLASS._loader.addModule({ name: "fcProfile", type: "js", fullpath: FIRSTCLASS.session.templatebase + "/firstclass/apps/Profile.js", requires: ['animation','imagecropper','fcFormDialog','container','containercore','button','fcBlog','fcBlogFeed','fcIntegration']}); }; FIRSTCLASS.preFetchScripts = function() { var requires = ["layout", "animation", "element", "fcCommunity", "fcHistory", "fcWiki", "fcDiscussion", "fcDocuments", "fcFormDialog", "fcListView", "fcProfile"]; FIRSTCLASS._loader.require(requires); FIRSTCLASS._loader.onSuccess = function(o) { /* finished prefetching */ }; FIRSTCLASS._loader.insert(); }; /** * load an application on an object * * @method loadApplication * @param {string} uri (required) the base uri of the object to open * @param {int} objType (required) the objType of the object to open * @param {int} subType (required) the subType of the object to open * @static */ FIRSTCLASS.loadApplication = function (uri, objType, subType, extparams) { if (YAHOO.widget.Logger) { YAHOO.widget.Logger.enableBrowserConsole(); } var loadFunc = function() { }; FIRSTCLASS._loader.onFailure = function(o) { alert("Unable to Load Application"); loadFunc(); }; var mydiv = document.createElement("div"); var fccontent = FIRSTCLASS.fcContentElement; var timestart = new Date(); var appConfig = { parentDiv: fccontent, baseUrl: uri, div:mydiv, onLoaded: loadFunc, onready: function() { fccontent.replaceChild(mydiv, fccontent.firstChild); }, logTime: function(message) { /* var timeend = new Date(); var diff = timeend.getTime() - timestart.getTime(); //if (console && console.log) { YAHOO.log("at " + diff + " ms, message:\"" + message + "\""); //}*/ } }; appConfig.logTime("loadApplication started"); if(extparams) { appConfig.params = extparams; } switch(objType) { case FIRSTCLASS.objTypes.conference: case FIRSTCLASS.objTypes.folder: if (subType == FIRSTCLASS.subTypes.profile) { FIRSTCLASS._loader.require(['fcProfile', 'fcDataSource', 'fcListView','tabview']); this._loader.onSuccess = function(o) { var myProfile= new FIRSTCLASS.apps.Profile(appConfig); }; break; } case FIRSTCLASS.objTypes.mailbox: FIRSTCLASS.apps.Desktop.instance.deactivate(); var reqMods = ['fcDataSource', 'fcListView']; var appName; if (subType==FIRSTCLASS.subTypes.music) { reqMods.push('fcMusic'); appName = "Music"; } else { reqMods.push('fcCommunity'); appName = "Community"; } FIRSTCLASS._loader.require(reqMods); this._loader.onSuccess = function(o) { appConfig.logTime("loadApplication code loaded, init'ing application"); var myApp = new FIRSTCLASS.apps[appName](appConfig); FIRSTCLASS.session.desktop.replaceDesktopItem(uri.substr(FIRSTCLASS.session.baseURL.length)); }; break; case FIRSTCLASS.objTypes.account: FIRSTCLASS._loader.require(['fcFormDialog']); this._loader.onSuccess = function(o) { FIRSTCLASS.apps.FormDialog.activeDialog = new FIRSTCLASS.apps.FormDialog({baseUrl: uri, onLoaded:loadFunc}); }; break; case FIRSTCLASS.objTypes.createcommunity: FIRSTCLASS._loader.require(['fcWorkflows']); this._loader.onSuccess = function(o) { var myApp = new FIRSTCLASS.apps.Workflows.CreateCommunity(); }; break; case FIRSTCLASS.objTypes.search: FIRSTCLASS.apps.Desktop.instance.deactivate(); FIRSTCLASS._loader.require(['fcSearch']); this._loader.onSuccess = function(o) { var mySearch = new FIRSTCLASS.apps.Search(appConfig); }; break; default: alert("FIRSTCLASS.loadApplication Bad ObjType "+objType); return; } FIRSTCLASS._loader.insert(); }; FIRSTCLASS.whatshot = function(params) { var mode = 1; var countfield = 0; var countparam = "&FieldID:1243%3DLONG=20"; var count = 0; if (!params.count) { params.count = 20; } if (params && params.what) { switch(params.what) { case "Communities": mode = 2; countfield = 1244 break; case "People": mode = 3; countfield = 1243; break; case "Both": default: mode = 1; } } if (params && params.count) { countparam = "&FieldID:" + countfield + "%3DLONG=" + params.count; count = params.count; } var baseurl = FIRSTCLASS.session.getActiveObject(); var searchpart = "__Search?FieldID:1234%3DLONG=2&FieldID:1246%3DLONG=1&FieldID:1229%3DLONG=0&FieldID:1238%3DLONG=1&FieldID:1239%3DLONG=1&FieldID:1211%3DLONG=0" + countparam; var searchurl = FIRSTCLASS.lang.ensureSlashUrl(baseurl) + searchpart; FIRSTCLASS.loadApplication(searchurl, FIRSTCLASS.objTypes.search, -1, {mode:mode, count: count, showoncomplete:params.showoncomplete}); }; FIRSTCLASS.search = function(config) { var baseurl = FIRSTCLASS.session.getActiveObject(); var key = escape(config.key); /* if (config.escapedkey) { key = config.escapedkey; }*/ var searchpart = "__Search?CharSet=UTF-8&FieldID:1211%3DLONG=0&FieldID:1246%3DLONG=1&FieldID:1234%3DLONG=0&FieldID:1229%3DLONG=0&FieldID:1238%3DLONG=1&FieldID:1239%3DLONG=1&FieldID:1202%3DSTRING=" + key; if (config.scope) { baseurl = config.scope; } var searchbox = $('fcSearchInput'); if (searchbox) { searchbox.value = config.key; } if (!config.escapedkey) { config.escapedkey = key; } var searchurl = FIRSTCLASS.lang.ensureSlashUrl(baseurl) + searchpart; FIRSTCLASS.loadApplication(searchurl, FIRSTCLASS.objTypes.search, -1, config); //var d = new Date(); //d.setTime(d.getTime() + 7*24*60*60*1000); //YAHOO.util.Cookie.set("fclastsearch", config.key, { expires: d}); }; FIRSTCLASS.apps.Desktop = function(config) { var that = this; this._config = config; this._title = "Home"; this._totalProfileComplete = -1; // used for keeping track of last known completeness percent for profile FIRSTCLASS.session.addHistoryEntry({"uri":FIRSTCLASS.session.baseURL,app:this}); this._domElement = $("fcDesktopContent"); this._bodyElement = FIRSTCLASS.ui.Dom.getChildByClassName("bd", this._domElement); //this.activateSideBar(); this.activate(true); if (FIRSTCLASS.session.user.isvirgin) { FIRSTCLASS.apps.Help.show(); } this.desktopIconList = $('fcDesktopIconList'); }; FIRSTCLASS.apps.Desktop.prototype.saveProfileStatus = function(curstatus) { this._config.profileStatus = curstatus; FIRSTCLASS.util.BuddyList.setMessage(curstatus); }; FIRSTCLASS.apps.Desktop.compareSubType = function(key, search) { if (key.subtype == parseInt(search)) { return true; } else { return false; } }; FIRSTCLASS.apps.Desktop.sortCommunities = function(row1, row2) { if (row1[1].name.toLowerCase() < row2[1].name.toLowerCase()) { return -1; } else if (row1[1].name.toLowerCase() > row2[1].name.toLowerCase()) { return 1; } else { return 0; } }; FIRSTCLASS.apps.Desktop.getCommunities = function() { var rows = FIRSTCLASS.session.desktop._dataSource.query("typedef", "66", false, FIRSTCLASS.apps.Desktop.compareSubType); rows.sort(FIRSTCLASS.apps.Desktop.sortCommunities); var nrows = []; for (var i in rows) { if (rows[i][1].col8092 == 0 && !rows[i][1].status.deleted) { nrows.push(rows[i][1]); } } return nrows; }; FIRSTCLASS.apps.Desktop.prototype.resizeEvent = function(evt) { var rgn = YAHOO.util.Dom.getRegion(this._bodyElement); var availablergn = YAHOO.util.Dom.getRegion($("fcRightContents").parentNode); var ht = FIRSTCLASS.ui.Dom.getViewportHeight()-rgn.top - 35; var aht = availablergn.bottom - availablergn.top - 70; if (aht > ht) { ht = aht; } if (!isNaN(ht) && ht >= 0) { YAHOO.util.Dom.setStyle(this._bodyElement, "height", ht + "px"); } }; FIRSTCLASS.apps.Desktop.prototype.activate = function() { FIRSTCLASS.ui.skin.clear(); FIRSTCLASS.session.setActiveObject(FIRSTCLASS.session.baseURL); FIRSTCLASS.session.setActiveApplication(this, "desktop"); FIRSTCLASS.ui.Dom.replaceContentsWithElement(FIRSTCLASS.fcContentElement, this._domElement); FIRSTCLASS.ui.navBar.setProfileUnread(0); this.activateSideBar(); if (this._dataSource) { this._dataSource.activate(); } FIRSTCLASS.ui.setDocumentTitle(FIRSTCLASS.session.user.name); FIRSTCLASS.ui.navBar.setTitleAndLink(FIRSTCLASS.session.user); this.resizeEvent(); if (this._notificationListView) { this._notificationListView.activate(); this._notificationListView.reLoadFromDataSource(); } if (this._watchListView) { this._watchListView.activate(); this._watchListView.reLoadFromDataSource(); } if (this._buddylistlv) { this._buddylistlv.activate(); this._buddylistlv.reLoadFromDataSource(); } YAHOO.util.Dom.setStyle(document.body, "height", "100%"); YAHOO.util.Dom.setStyle(document.body, "overflow", ""); if (YAHOO.env.ua.ie < 8) { document.body.setAttribute('scroll','auto'); } var that = this; if (FIRSTCLASS.ui.leftSideBar.isHidden()) { FIRSTCLASS.ui.leftSideBar.show(); FIRSTCLASS.ui.sideBar.showApplicationBox(FIRSTCLASS.locale.desktop.people); } }; FIRSTCLASS.apps.Desktop.prototype.deactivate = function() { if (this._dataSource) { this._dataSource.deactivate(); } if (this._notificationListView) { this._notificationListView.deactivate(); } if (this._buddylistlv) { this._buddylistlv.deactivate(); } if (this._watchListView) { this._watchListView.deactivate(); } FIRSTCLASS.ui.MiniProfile.hideBoxNow(); }; FIRSTCLASS.apps.Desktop.prototype.isItemBeingWatched = function(row) { if (row.typedef.objtype == FIRSTCLASS.objTypes.odocument) { return this.isThreadBeingWatched(row.threadid); } else if (this._dataSource) { var rows = this._dataSource.query("threadid", row.messageid, true); for(var i in rows) { var r = rows[i][1]; if (r.col8092 && (r.col8092 == 1 || r.col8092 == 2) && r.status && !r.status.deleted == 1) { return true; } } } return false; }; FIRSTCLASS.apps.Desktop.prototype.isThreadBeingWatched = function(tid) { if (this._dataSource) { var rows = this._dataSource.query("threadid", tid, true); for(var i in rows) { var row = rows[i][1]; if (row.status && (row.status.deleted == 1)) return false; if (row.col8092 && (row.col8092 == 1 || row.col8092 == 2) && row.status && !row.status.deleted == 1) { return true; } } } return false; }; FIRSTCLASS.apps.Desktop.prototype.toggleUnreadOnWatches = function(tid) { if (this._dataSource) { var rows = this._dataSource.query("threadid", tid, true); for(var i in rows) { var row = rows[i][1]; if (row.col8092 && (row.col8092 == 1 || row.col8092 == 2) && (row.status && !row.status.deleted || !row.status)) { this._dataSource.toggleUnRead(row, 0); } } } }; FIRSTCLASS.apps.Desktop.prototype.isContainerBeingWatched = function(baseurl) { if (this._dataSource) { var newurlpart = baseurl.replace("FAV1", "FLV1").replace("FOV1", "FLV1"); newurlpart = FIRSTCLASS.lang.removeSlashUrl(newurlpart.substr(newurlpart.indexOf("FLV1"))); var rows = this._dataSource.query("uri", newurlpart, true); for(var i in rows) { var row = rows[i][1]; if (row.col8092 && (row.col8092 == 4) && row.status && !row.status.deleted) { return true; } } } return false; }; FIRSTCLASS.apps.Desktop.prototype.stopContainerBeingWatched = function(baseurl) { if (this._dataSource) { var newurlpart = baseurl.replace("FAV1", "FLV1").replace("FOV1", "FLV1"); newurlpart = FIRSTCLASS.lang.removeSlashUrl(newurlpart.substr(newurlpart.indexOf("FLV1"))); if (newurlpart.length == 13) var rows = this._dataSource.query("uri", newurlpart, true); for(var i in rows) { var row = rows[i][1]; if (row.col8092 && (row.col8092 == 4) && (row.status && !row.status.deleted || !row.status)) { this._dataSource.deleteRow(row); } } } }; FIRSTCLASS.apps.Desktop.prototype.deleteWatch = function(row) { if (this._dataSource && row.threadid != "0" && row.messageid != "0") { var rows = this._dataSource.query("threadid", row.messageid, true); if (rows.length > 0) { for(var i in rows) { var r = rows[i][1]; if (r.col8092 && (r.col8092 == 2 || r.col8092 == 4) && (r.status && !r.status.deleted || !r.status)) { this._dataSource.deleteRow(r); } } } else { var r; rows = this._dataSource.query("threadid", row.threadid, true); for(var i in rows) { r = rows[i][1]; if (r.col8092 && ((r.col8092 == 2) || (r.col8092 == 4)) && (r.status && !r.status.deleted || !r.status)) this._dataSource.deleteRow(r); } } } }; FIRSTCLASS.apps.Desktop.prototype.deleteDesktopItem = function(uri) { var rows = this._dataSource.query("uri", FIRSTCLASS.lang.removeSlashUrl(uri), true, function(key, search) { var newkey = FIRSTCLASS.lang.removeSlashUrl(key); var newsearch = FIRSTCLASS.lang.removeSlashUrl(search); return (newkey.indexOf(newsearch) >= 0); }); var that =this; if (rows.length > 0) { var answer = false; if(!rows[0][1].status.alias) { answer=confirm(FIRSTCLASS.locale.desktop.delconfirm); } else { var question = FIRSTCLASS.locale.desktop.unsubconfirm[rows[0][1].typedef.subtype]; if (question) { answer=confirm(question); } else { answer = true; } } if (answer) { if (that.isContainerBeingWatched(rows[0][1].uri) && (rows[0][1].col8092 && rows[0][1].col8092 == 3 || rows[0][1].col8092 && rows[0][1].col8092 == 0 || !rows[0][1].col8092)) { that.stopContainerBeingWatched(rows[0][1].uri); } that._dataSource.deleteRow(rows[0][1]); that.deleteDesktopIconByRow(rows[0][1]); } } }; FIRSTCLASS.apps.Desktop.prototype.deleteDesktopIconByRow = function(row) { var icon = this.getDesktopItem(row); if (icon){ icon.parentNode.removeChild(icon); delete icon; } }; FIRSTCLASS.apps.Desktop.prototype.eventHandlers = { click: { deskdelete: function(that, fcevent) { that.deleteDesktopItem(fcevent.fcattrs); }, unread: function(that, fcevent) { var uri = fcevent.fcattrs; var rows = that._dataSource.query("uri", FIRSTCLASS.lang.removeSlashUrl(uri), true, function(key, search) { var newkey = FIRSTCLASS.lang.removeSlashUrl(key); var newsearch = FIRSTCLASS.lang.removeSlashUrl(search); return (newkey.indexOf(newsearch) >= 0); }); if (rows.length > 0) { that._dataSource.toggleUnRead(rows[0][1], 0); } }, diaccept: function(that, fcevent) { that.acceptItem(fcevent.fcattrs); }, dimore: function(that, fcevent) { that.doMore(fcevent.fcattrs); } } }; FIRSTCLASS.apps.Desktop.prototype.handleEvent = function(evt, fcevent) { var handlers = this.eventHandlers[evt.type]; var rv = false; if (handlers) { var handler = handlers[fcevent.fcid]; if (handler) { rv = handler(this, fcevent); if (typeof rv == "undefined") { rv = true; } } } return rv; }; FIRSTCLASS.apps.Desktop.prototype.acceptItem = function(uri) { var rows = this._dataSource.query("uri", FIRSTCLASS.lang.removeSlashUrl(uri), true, function(key, search) { var newkey = FIRSTCLASS.lang.removeSlashUrl(key); var newsearch = FIRSTCLASS.lang.removeSlashUrl(search); return (newkey.indexOf(newsearch) >= 0); }); if (rows.length) { var row = rows[0][1]; var joinurl = FIRSTCLASS.session.baseURL + '?LFieldID_8092.'+FIRSTCLASS.lang.removeSlashUrl(row.uri)+'_LONG=0&Templates=JS'; YAHOO.util.Connect.asyncRequest('GET', joinurl); row.col8092 = 0; this._dataSource.notifyRowDeleted(row); this._dataSource.notifyRowChanged(row); } } FIRSTCLASS.apps.Desktop.prototype.doMore = function(uri) { var that = this; var rows = this._dataSource.query("uri", FIRSTCLASS.lang.removeSlashUrl(uri), true, function(key, search) { var newkey = FIRSTCLASS.lang.removeSlashUrl(key); var newsearch = FIRSTCLASS.lang.removeSlashUrl(search); return (newkey.indexOf(newsearch) >= 0); }); if (rows.length) { var row = rows[0][1]; if (row.col8092 && row.col8092 == 3) { FIRSTCLASS._loader.require(['fcWorkflows']); FIRSTCLASS._loader.onSuccess = function(o) { var config = { dataSource: that._dataSource, row: row, domElement: document.createElement("div") }; var ap = FIRSTCLASS.apps.Workflows.Invitation(config); }; FIRSTCLASS._loader.insert(); } else { var uri = row.uri; var icon = row.icon.uri; that._dataSource.toggleUnRead(row, 0); var parts = uri.split("-"); var potentials = this._dataSource.query("uri", parts[1], true, function(key, search) { return (key.indexOf(search) >= 0); }); var actual = false; for (var i in potentials) { if (typeof potentials[i][1].col8092 == "undefined" || potentials[i][1].col8092 == 0) { actual = potentials[i][1]; break; } } var params = { title: row.col14, uri: row.uri, itemthread: row.threadid }; var subtype = FIRSTCLASS.subTypes.community; if (row.col14 == "Profile") { FIRSTCLASS.loadApplication(FIRSTCLASS.util.User.getProfileUrlByCid(row.creatorcid), FIRSTCLASS.objTypes.folder, FIRSTCLASS.subTypes.profile, {uid: row.creatorcid, name: "", itemthread:row.threadid}); } else { if (actual) { params.uri = actual.uri; params.icon = actual.icon.uri; if (actual.lconfcid) { params.lconfcid = actual.lconfcid; } } FIRSTCLASS.loadApplication(FIRSTCLASS.lang.ensureSlashUrl(FIRSTCLASS.session.domain + FIRSTCLASS.lang.ensureSlashUrl(FIRSTCLASS.session.baseURL)+uri), FIRSTCLASS.objTypes.conference, subtype, params); } } } }; FIRSTCLASS.apps.Desktop.prototype.getDesktopItem = function(row) { var icon = $('fcDesktopIcon'+FIRSTCLASS.lang.removeSlashUrl(row.uri)); if (typeof icon == "undefined" || icon === null) { icon = FIRSTCLASS.ui.Dom.getChildByIdName('fcDesktopIcon'+FIRSTCLASS.lang.removeSlashUrl(row.uri), this.desktopIconList); } return icon; }; FIRSTCLASS.apps.Desktop.prototype.replaceDesktopItem = function(uri) { var rows = FIRSTCLASS.apps.Desktop.instance._dataSource.query("uri", uri, true); for(var i in rows) { var newdiv = this.addDesktopItem(rows[i][1], true); var olddiv = $(newdiv.id); if (!olddiv) { olddiv = FIRSTCLASS.ui.Dom.getChildByIdName(newdiv.id, this.desktopIconList); } if (olddiv) { this.desktopIconList.replaceChild(newdiv, olddiv); } } }; FIRSTCLASS.apps.Desktop.prototype.addDesktopItem = function(row, returndiv) { var html = []; html.push('
'); html.push('
'); html.push('
'); html.push(''); html.push('
'); html.push('
'); html.push('
'); html.push('
'); html.push('
'); html.push(''+FIRSTCLASS.lang.mlesc(row.name)+'
'); html.push('
'); var div = document.createElement('div'); div.innerHTML = html.join(""); if (!returndiv) { FIRSTCLASS.ui.Dom.reparentNode(div.firstChild, this.desktopIconList); } this.updateDesktopItem(row, div.firstChild); if (returndiv) { return div.firstChild; } }; FIRSTCLASS.apps.Desktop.prototype.updateDesktopItem = function(row, div) { var icon; if (div) { icon = div; } else { icon = this.getDesktopItem(row); } icon.setAttribute('fcid', 'community,ihover'); icon.setAttribute('fcattrs', row.uri); icon.firstChild.setAttribute('fcid', 'community'); icon.firstChild.setAttribute('fcattrs', row.uri); icon.firstChild.childNodes[1].setAttribute('fcid', 'community'); icon.firstChild.childNodes[1].setAttribute('fcattrs', row.uri); var aicon = icon.childNodes[0].childNodes[0].childNodes[0]; aicon.setAttribute('fcid', 'community'); aicon.setAttribute('fcattrs', row.uri); if (aicon.src != row.icon.uri) { aicon.src=row.icon.uri; } var unread = icon.childNodes[0].childNodes[0].childNodes[1]; YAHOO.util.Dom.removeClass(unread, 'fcIconFlagNone'); YAHOO.util.Dom.removeClass(unread, 'fcIconFlag'); YAHOO.util.Dom.removeClass(unread, 'fcIconFlagWide1'); YAHOO.util.Dom.removeClass(unread, 'fcIconFlagWide2'); if (row.status.unread == 0) { YAHOO.util.Dom.addClass(unread, 'fcIconFlagNone'); } else if (row.status.unread < 10) { YAHOO.util.Dom.addClass(unread, 'fcIconFlag'); unread.innerHTML = row.status.unread; } else if (row.status.unread < 100) { YAHOO.util.Dom.addClass(unread, 'fcIconFlagWide1'); unread.innerHTML = row.status.unread; } else if (row.status.unread < 1000) { YAHOO.util.Dom.addClass(unread, 'fcIconFlagWide2'); unread.innerHTML = row.status.unread; } else { YAHOO.util.Dom.addClass(unread, 'fcIconFlagWide2'); unread.innerHTML = FIRSTCLASS.locale.desktop.lots; } if (row.status.unread) { unread.setAttribute('fcid', 'unread'); unread.setAttribute('fcattrs', row.uri); } if (row.status.protected) { YAHOO.util.Dom.addClass(icon, 'fcProtected') } }; FIRSTCLASS.apps.Desktop.prototype.caclProfileCompleteness = function(profileData) { var profileDataCompleteness = new Array(); profileDataCompleteness[0] = {whatPart: profileData.image, showText: FIRSTCLASS.locale.profileCompleteness.photo, percent: 25, fieldID: "img"}; profileDataCompleteness[1] = {whatPart: profileData.bio, showText: FIRSTCLASS.locale.profileCompleteness.bio, percent: 15, fieldID: 3019}; profileDataCompleteness[2] = {whatPart: profileData.expertise, showText: FIRSTCLASS.locale.profileCompleteness.expertise, percent: 10, fieldID: 3012}; profileDataCompleteness[3] = {whatPart: profileData.phone, showText: FIRSTCLASS.locale.profileCompleteness.phone, percent: 10, fieldID: 3010}; profileDataCompleteness[4] = {whatPart: profileData.manager, showText: FIRSTCLASS.locale.profileCompleteness.manager, percent: 10, fieldID: -3002}; profileDataCompleteness[5] = {whatPart: profileData.IM, showText: FIRSTCLASS.locale.profileCompleteness.im, percent: 10, fieldID: 2017}; profileDataCompleteness[6] = {whatPart: profileData.department, showText: FIRSTCLASS.locale.profileCompleteness.department, percent: 10, fieldID: -3024}; profileDataCompleteness[7] = {whatPart: profileData.education, showText: FIRSTCLASS.locale.profileCompleteness.education, percent: 10, fieldID: -3013}; if (profileData.IMType == -1) //user has never chosen which IM to use profileDataCompleteness[5].whatPart = 0; else if (profileData.IMType == 0) // use has specifically said NO IM profileDataCompleteness[5].whatPart = 1; var index; var useThis; var firstFoundIndex = -1; var totalComplete = 100; var theLen = profileDataCompleteness.length; for (index=0; index < theLen; ++index) { if (profileDataCompleteness[index].whatPart == 0) { if (firstFoundIndex==-1) { firstFoundIndex = index; useThis = profileDataCompleteness[index]; } totalComplete = totalComplete - profileDataCompleteness[index].percent; } } if (this._totalProfileComplete != totalComplete) { this._totalProfileComplete = totalComplete; if (totalComplete < 100) { this._createProfileBarGraph(totalComplete,useThis.showText,useThis.percent,useThis.fieldID); } else { FIRSTCLASS.ui.sideBar.hideApplicationBox(FIRSTCLASS.locale.desktop.prof); } } } FIRSTCLASS.apps.Desktop.prototype._createProfileBarGraph = function(totalComplete,nextItem,nextPercent,nextFieldID) { var barGraph = "
Percent completed
" this._profileinfo.innerHTML = "" + barGraph + FIRSTCLASS.locale.doSub(FIRSTCLASS.locale.profileCompleteness.percent,{prcnt:totalComplete,nextitem:nextItem,nextlevel:totalComplete + nextPercent}) + ""; YAHOO.util.Event.purgeElement(this._profileinfo, true); YAHOO.util.Dom.setStyle(this._profileinfo,"cursor","pointer"); if (nextItem=="image") { YAHOO.util.Event.addListener(this._profileinfo, 'click', function(evt) { FIRSTCLASS.loadApplication(FIRSTCLASS.util.User.getProfileUrlByCid(FIRSTCLASS.session.user.cid), FIRSTCLASS.objTypes.folder, FIRSTCLASS.subTypes.profile, {uid: FIRSTCLASS.session.user.cid, name: FIRSTCLASS.session.user.name,editProfile:"img"}); YAHOO.util.Event.stopPropagation(evt); }); } else { YAHOO.util.Event.addListener(this._profileinfo, 'click', function(evt) { FIRSTCLASS.loadApplication(FIRSTCLASS.util.User.getProfileUrlByCid(FIRSTCLASS.session.user.cid), FIRSTCLASS.objTypes.folder, FIRSTCLASS.subTypes.profile, {uid: FIRSTCLASS.session.user.cid, name: FIRSTCLASS.session.user.name,editProfile:nextFieldID}); YAHOO.util.Event.stopPropagation(evt); }); } FIRSTCLASS.ui.sideBar.showApplicationBox(FIRSTCLASS.locale.desktop.prof); } FIRSTCLASS.apps.Desktop.prototype.updateProfileInfo = function(profileData) { this._profileContents = profileData; var noProfile = ((typeof profileData.type != 'undefined') && (profileData.type=="error")); var that = this; var existsCB = { success: function(o) { profileData.image = 1; that.caclProfileCompleteness(profileData); }, failure: function(o) { if (noProfile) that._createProfileBarGraph(0,"image",25,"img"); else { profileData.image = 0; that.caclProfileCompleteness(profileData); } } }; YAHOO.util.Connect.asyncRequest('HEAD',FIRSTCLASS.util.User.getLargeProfPicUrlByCid(FIRSTCLASS.session.user.cid,false),existsCB); }; FIRSTCLASS.apps.Desktop.prototype.animateDiv = function(divid) { YAHOO.util.Event.onAvailable(divid, function() { var myAnim = new YAHOO.util.ColorAnim(this, {backgroundColor: { from: '#e76300', to: '#202946' } },2); myAnim.onComplete.subscribe(function() { var div = $(divid); YAHOO.util.Dom.setStyle(div, 'background', 'transparent'); }); myAnim.animate(); }); }; FIRSTCLASS.apps.Desktop.prototype.activateSideBar = function() { }; FIRSTCLASS.apps.Desktop.prototype.updateStatsCounters = function(stats) { if (!stats && this._stats) { stats = this._stats; } else if (!stats) { return; } var communityStats = $('fcCommunityStats'); if (communityStats == null) return; var nsubscriptions = 0; var noriginals = 0; var nfollowed = 0; for (var i in this._dataSource._data.records) { var row = this._dataSource._data.records[i]; if (row.status.deleted == 0) { if (row.typedef.subtype == 66 && row.status.alias) { nsubscriptions++; } if (row.typedef.subtype == 66 && !row.status.alias) { noriginals++; } if (row.typedef.subtype == 33 && row.status.alias) { nfollowed++; } } } var communitiesstr = noriginals + " " + FIRSTCLASS.locale.desktop.summ.originals + ", " + nsubscriptions + " " + FIRSTCLASS.locale.desktop.summ.subscriptions + ", " + stats.fcpSysCommunities + " " + FIRSTCLASS.locale.desktop.summ.total + ", " + stats.fcpSysCommPosts + " " + FIRSTCLASS.locale.desktop.summ.items + ""; communityStats.innerHTML = communitiesstr; var peoplestr = "
" + nfollowed + " " + FIRSTCLASS.locale.desktop.summ.followed + ", " + stats.fcpSysUsersTotal + " " + FIRSTCLASS.locale.desktop.summ.total + ", " + stats.fcpSysUsersOnline + " " + FIRSTCLASS.locale.desktop.summ.online + "
"; var subheader = document.createElement("div"); subheader.innerHTML = peoplestr; FIRSTCLASS.ui.leftSideBar.updateBoxSubHeader(FIRSTCLASS.locale.desktop.people, subheader); this._stats = stats; }; FIRSTCLASS.apps.Desktop.prototype.init = function() { //FIRSTCLASS.apps.Desktop.prototype.initSideBar = function() { var that = this; // init = function() { /*var hoverboxfunc = function(hoverBox,domElement, listelement, hbox) { FIRSTCLASS.ui.widgets.miniProfile(hoverBox,domElement, listelement, hbox); };*/ var dsconfig = { containerBaseUrl:FIRSTCLASS.session.baseURL, itemrequest: false, loadFull: true, watchForTinkle: true, closeParam: "&Close=-1", nosymbiomainfetch: true, paramStr: "&Watches=1&Communities=1&People=1", compareRows: function(row1, row2) { return row1.status.unread == row2.status.unread && row1.name == row2.name && row1.online == row2.online; }, isSameRow: function(row1, row2) { return row1.uri == row2.uri; }, startondomready: true }; if (FIRSTCLASS._temporary && FIRSTCLASS._temporary.desktopJSON) { dsconfig.prePopulateData = FIRSTCLASS._temporary.desktopJSON; FIRSTCLASS._temporary.desktopJSON = false; } that._dataSource = new FIRSTCLASS.util.DataSource(dsconfig); that._dataSource.activate(); that._dataSource.addDataListener({ onHeaderData:function(key, contents) { switch(key) { case "profile": that.updateProfileInfo(contents); break; case "tags": that.personaltags = FIRSTCLASS.ui.parseServerTags(contents); if (that._tags) { that._tags.innerHTML = FIRSTCLASS.ui.generateCloud(that.personaltags); } break; case "stats": that.updateStatsCounters(contents); default: break; } }, filter:function(key) { switch(key) { case "profile": case "tags": case "stats": return true; default: return false; } } }); that.rowHandler = { notifications: 0, fillCount: 0, onRow: function(row, dataSource, atEnd, hasMore) { if (row.typedef.objtype == 1 && row.typedef.subtype == FIRSTCLASS.subTypes.community && (typeof row.col8092 == "undefined" || row.col8092 == 0)) { var exists = that.getDesktopItem(row); if (exists) { that.updateDesktopItem(row); } else if(row.status.deleted == 0) { that.addDesktopItem(row); } } if (FIRSTCLASS.appProperties.soundsSupported) { if (row.col8092 && row.col8092 == 3 && this.fillCount > 1) { soundManager.play("watch1"); that.animateDiv(that._notificationListView._generateDivID(row)); } } if (row.typedef.subtype == FIRSTCLASS.subTypes.profile && !row.status.alias) { FIRSTCLASS.ui.navBar.setProfileUnread(row.status.unread, row.uri); } if (typeof row.online != "undefined") { FIRSTCLASS.session.UserStatuses.updateStatus(row.cid, row.online); } }, onRowChanged:function(row, dataSource, oldrow) { try { if (row.typedef.objtype == 1 && row.typedef.subtype == FIRSTCLASS.subTypes.community && (typeof row.col8092 == "undefined" || row.col8092 == 0)) { var exists = that.getDesktopItem(row); if (exists) { that.updateDesktopItem(row); } else if (row.status.deleted == 0) { that.addDesktopItem(row); } } if (FIRSTCLASS.appProperties.soundsSupported) { if (row.status && row.col8092 && row.col8092 == 2 && row.status.unread && !oldrow.status.unread && this.fillCount > 1) { soundManager.play("watch1"); that.animateDiv(that._watchListView._generateDivID(row)); } else if (typeof row.online != "undefined") { if (row.online && !oldrow.online) { soundManager.play("contact1"); that.animateDiv(that._buddylistlv._generateDivID(row)); } else if (!row.online && oldrow.online){ soundManager.play("contact2"); that.animateDiv(that._buddylistlv._generateDivID(row)); } } if (row.status && oldrow && row.status.unread && !oldrow.status.unread) { soundManager.play("paper"); } } if (typeof row.online != "undefined") { FIRSTCLASS.session.UserStatuses.updateStatus(row.cid, row.online); } if (FIRSTCLASS.extensions) { if (typeof row.online != "undefined" && row.status.alias) { if (row.online && !oldrow.online && row.uid != FIRSTCLASS.session.user.cid) { FIRSTCLASS.extensions.notify(row.name + " has signed on", row.message, FIRSTCLASS.session.templatebase + "/firstclass/images/online.png"); } else if (row.message != oldrow.message && row.uid != FIRSTCLASS.session.user.cid) { FIRSTCLASS.extensions.notify(row.name + " has changed their status", row.message, FIRSTCLASS.session.templatebase + "/firstclass/images/topic.png"); } } else if (row.status && oldrow && row.status.unread && !oldrow.status.unread) { FIRSTCLASS.extensions.notify("New Messages in \"" + row.name + "\"", row.status.unread + " new messages are available in the Community \"" + row.name + "\"", row.icon.uri); } } if (row.typedef.subtype == FIRSTCLASS.subTypes.profile && !row.status.alias) { FIRSTCLASS.ui.navBar.setProfileUnread(row.status.unread, row.uri); } } catch (err) { } }, onRefill:function(dataSource) { //that._contentsDomElement.innerHTML = ""; }, onRowDeleted:function(row, dataSource) { that.deleteDesktopIconByRow(row); }, fillFinished:function(isNewDelivery, isOnAddNewListener) { this.fillCount++; if (!isOnAddNewListener && that._config.callbacks && that._config.callbacks.onload) { that._config.callbacks.onload(); that._config.callbacks = false; } } }; FIRSTCLASS.util.BuddyList.setDataSource(that._dataSource); that._buddylist = document.createElement("div"); if (that._buddylist) { //that._hoverBox = new FIRSTCLASS.ui.HoverBox(hoverboxfunc, 300, {w:400, h:250}, that._buddylist); var buddylistcfg = { domElement: that._buddylist, dataSource: that._dataSource, keepRowsSorted: true, threading: { format: FIRSTCLASS.layout.ThreadHandler.types.NONE, sortfunc: function(row1, row2) { var weight1 = "9999"; if (row1.online > 0) { weight1 = "1111"; } if (row1.status.unread) { weight1 = "0000"; } var weight2 = "9999"; if (row2.online > 0) { weight2 = "1111"; } if (row2.status.unread) { weight2 = "0000"; } var str1 = weight1 + row1.name; var str2 = weight2 + row2.name; if (str1 > str2) { return 1; } else if (str1 == str2) { return 0; } else { return -1; } } }, rowFilter: function(row) { return (row.typedef.subtype == FIRSTCLASS.subTypes.profile && row.status.alias && row.status.deleted == 0); }, onFillFinished: function() { if (that._dataSource.isActive()) { /*if ((!that._buddylistlv || (that._buddylistlv && !that._buddylistlv.hasChildren()))) { FIRSTCLASS.ui.sideBar.hideApplicationBox(FIRSTCLASS.locale.desktop.people); } else*/ { if (FIRSTCLASS.ui.leftSideBar.isHidden()&& (FIRSTCLASS.session.getActiveApplicationName()=="desktop")) { FIRSTCLASS.ui.leftSideBar.show(false, function() { FIRSTCLASS.ui.sideBar.showApplicationBox(FIRSTCLASS.locale.desktop.people); }); } } } }, rowHandler: new FIRSTCLASS.layout.UserListHandler(that._dataSource/*, that._hoverBox*/) }; that._buddylistlv = new FIRSTCLASS.layout.ListView(buddylistcfg); } var tbElem = document.createElement("DIV"); var tbConfig = { domElement: tbElem, buttons: [ {id: "editmyprofile", label: "edit profile", click: function(evt) { FIRSTCLASS.loadApplication(FIRSTCLASS.util.User.getProfileUrlByCid(FIRSTCLASS.session.user.cid),FIRSTCLASS.objTypes.folder, FIRSTCLASS.subTypes.profile); }} ]}; that._dataSource.addRowListener(that.rowHandler); var toolBar = new FIRSTCLASS.ui.toolBar(tbConfig); that._notifications = document.createElement("div"); var notificationlistcfg = { domElement: that._notifications, dataSource: that._dataSource, threading: { format: FIRSTCLASS.layout.ThreadHandler.types.NONE, sortfunc: function(row1, row2) { return row1.subject >= row2.subject; } }, rowFilter: function(row) { return (row.col8092 && row.col8092 == 3 && row.status.deleted == 0); }, onFillFinished: function(listview) { if (!listview || (listview && !listview.hasChildren())) { FIRSTCLASS.ui.sideBar.hideApplicationBox(FIRSTCLASS.locale.desktop.invitations); } else { FIRSTCLASS.ui.sideBar.showApplicationBox(FIRSTCLASS.locale.desktop.invitations); } }, rowHandler: new FIRSTCLASS.layout.DesktopItemHandler(that._dataSource) }; that._notificationListView = new FIRSTCLASS.layout.ListView(notificationlistcfg); that._watches = document.createElement("div"); var watchlistcfg = { domElement: that._watches, dataSource: that._dataSource, keepRowsSorted: true, threading: { format: FIRSTCLASS.layout.ThreadHandler.types.NONE, sortfunc: function(row1, row2) { var weight1 = row1.status.unread?"0001":"1000"; var weight2 = row2.status.unread?"0001":"1000"; var str1 = weight1 + row1.name; var str2 = weight2 + row2.name; if (str1 > str2) { return 1; } else if (str1 == str2) { return 0; } else { return -1; } //return str1 >= str2; } }, rowFilter: function(row) { return (row.col8092 && (row.col8092 == 1 || row.col8092 == 2) && row.status.deleted == 0); }, onFillFinished: function(listview) { if (!listview || (listview && !listview.hasChildren())) { FIRSTCLASS.ui.sideBar.hideApplicationBox(FIRSTCLASS.locale.desktop.watches); } else { FIRSTCLASS.ui.sideBar.showApplicationBox(FIRSTCLASS.locale.desktop.watches); } }, rowHandler: new FIRSTCLASS.layout.DesktopItemHandler(that._dataSource) }; that._watchListView = new FIRSTCLASS.layout.ListView(watchlistcfg); that._profileinfo = document.createElement("div"); that._profileinfo.innerHTML = "Click here to create your profile"; YAHOO.util.Dom.setStyle(that._profileinfo,"cursor","pointer"); YAHOO.util.Event.addListener(that._profileinfo, 'click', function(evt) { FIRSTCLASS.loadApplication(FIRSTCLASS.util.User.getProfileUrlByCid(FIRSTCLASS.session.user.cid), FIRSTCLASS.objTypes.folder, FIRSTCLASS.subTypes.profile, {cid: FIRSTCLASS.session.user.cid, uid: FIRSTCLASS.session.user.userid, name: FIRSTCLASS.session.user.name,editProfile:1}); YAHOO.util.Event.stopPropagation(evt); }); YAHOO.util.Dom.addClass(that._profileinfo, 'fcProfileUpdateInfo'); that._tags = document.createElement("div"); var tags = [{tag:FIRSTCLASS.locale.desktop.tag.info, weight:1, clickable:false}]; that._tags.innerHTML = FIRSTCLASS.ui.generateCloud(tags); that._shout = document.createElement("DIV"); that._shout.innerHTML="
Fire Drill at 12:30pm
We will be having a fire drill at 12:30pm today, please plan accordingly.
more
"; //that.rightSideBar.addApplicationBox(that._shout, "SHOUT", function() {}); that.activateSideBar = function() { var date = new Date(); if (FIRSTCLASS.skin && FIRSTCLASS.skin.desktop && FIRSTCLASS.skin.desktop.sidebars) { FIRSTCLASS.ui.leftSideBar.resetApplicationBoxContents(); if (FIRSTCLASS.skin.desktop.sidebars.left.visible) { FIRSTCLASS.ui.leftSideBar.show(); for (var i in FIRSTCLASS.skin.desktop.sidebars.left.contents) { that.buildApplicationBox(FIRSTCLASS.ui.leftSideBar, FIRSTCLASS.skin.desktop.sidebars.left.contents[i]); } } else { FIRSTCLASS.ui.leftSideBar.hide() } FIRSTCLASS.ui.rightSideBar.resetApplicationBoxContents(); if (FIRSTCLASS.skin.desktop.sidebars.right.visible) { FIRSTCLASS.ui.rightSideBar.show(); for (var i in FIRSTCLASS.skin.desktop.sidebars.right.contents) { that.buildApplicationBox(FIRSTCLASS.ui.rightSideBar, FIRSTCLASS.skin.desktop.sidebars.right.contents[i]); } } else { FIRSTCLASS.ui.rightSideBar.hide() } } else { FIRSTCLASS.ui.rightSideBar.resetApplicationBoxContents(); FIRSTCLASS.ui.rightSideBar.show(); FIRSTCLASS.ui.rightSideBar.addApplicationBox(that._profileinfo, FIRSTCLASS.locale.desktop.prof,null,true); if (typeof that._profileContents != 'undefined') { that._totalProfileComplete = -1; that.updateProfileInfo(that._profileContents); } FIRSTCLASS.ui.rightSideBar.addApplicationBox(that._notifications, FIRSTCLASS.locale.desktop.invitations); if (that._notificationListView && !that._notificationListView.hasChildren()) { FIRSTCLASS.ui.sideBar.hideApplicationBox(FIRSTCLASS.locale.desktop.invitations); } FIRSTCLASS.ui.rightSideBar.addApplicationBox(that._watches, FIRSTCLASS.locale.desktop.watches); if (that._watchListView && !that._watchListView.hasChildren()) { FIRSTCLASS.ui.sideBar.hideApplicationBox(FIRSTCLASS.locale.desktop.watches); } FIRSTCLASS.ui.rightSideBar.addApplicationBox(that._tags, FIRSTCLASS.locale.desktop.tag.lbl); FIRSTCLASS.ui.leftSideBar.resetApplicationBoxContents(); FIRSTCLASS.ui.leftSideBar.addApplicationBox(that._buddylist, FIRSTCLASS.locale.desktop.people, "#__Discover?What=People&Count=20", false, false, FIRSTCLASS.locale.desktop.discover); } FIRSTCLASS.ui.navBar.setSmallUserProfilePicture(null,FIRSTCLASS.session.user.cid,FIRSTCLASS.session.user.name,date.getTime()); FIRSTCLASS.ui.navBar.setProfileStatus(that._config.profileStatus, that); FIRSTCLASS.ui.navBar.setTitleAndLink(FIRSTCLASS.session.user); }; // }; /*FIRSTCLASS._loader.require(); FIRSTCLASS._loader.onSuccess = function(o) { init(); that.activateSideBar(); }; FIRSTCLASS._loader.insert();*/ }; FIRSTCLASS.apps.Desktop.prototype.buildApplicationBox = function(sidebar, boxinfo) { switch(boxinfo.type) { case "embed": boxinfo.div = document.createElement("div"); sidebar.addApplicationBox(boxinfo.div, boxinfo.title); if (boxinfo.html) { boxinfo.div.innerHTML = boxinfo.html; } else if (boxinfo.url) { boxinfo.div.innerHTML = "