/** * Class Description * @module firstclass * @title FIRSTCLASS Global */ if (typeof FIRSTCLASS === "undefined" || !FIRSTCLASS) { var FIRSTCLASS = {}; } FIRSTCLASS.setTimeout = function(func, timeout) { return window.setTimeout(func, timeout); }; FIRSTCLASS.setInterval = function(func, timeout) { return window.setInterval(func, timeout); }; var $ = function (identifier) { return document.getElementById(identifier); }; String.prototype.trim = function () { return this.replace(/^\s+|\s+$/g, ""); }; Object.size = function(obj) { var size = 0, key; for (key in obj) { if (obj.hasOwnProperty(key)) { size++; } } return size; }; String.prototype.parseURLS = function (maxlength, maxubslength) { return this.preprocess({urls: true, maxurl: maxlength, maxstr: maxubslength}); }; String.prototype.preprocess = function (cfg) { var breakchar = " "; if (cfg.breakchar) { breakchar = cfg.breakchar; } var dourls = cfg.urls, maxlength = cfg.maxurl, maxubslength = cfg.maxstr, that = this, 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 isUrl = function (s) { var regexp = /[A-Za-z]:\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#_!:.?+=&%@!\-\/]))?/; return regexp.test(s); }, 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 > 1 && bits[1].length > 1 && bits[2].length > 1) { return true; } } else if (bits.length === 2 && bits[0].length > 1 && bits[1].indexOf("\/") > 0) { return true; } return false; }, makelink = function (s) { return "" + s + ""; }, scan = function (start, end) { var segStart = start, c = "", pos = start, seg = "", found = false, seg2, outseg; 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); seg2 = seg; if (maxlength && seg2.length > maxlength) { seg2 = seg.substr(0,maxlength) + "..."; } if (dourls && isUrl(seg)) { outStr += "" + seg2 + ""; } else if (dourls && isUrlNoProtocol(seg)) { outStr += "" + seg2 + ""; } else if (dourls && FIRSTCLASS.lang.isEmailAddress(seg)) { outStr += "" + seg2 + ""; } else { outseg = seg; if (maxubslength) { if (seg.length > maxubslength) { outseg = ""; while (seg.length > 0) { outseg += seg.slice(0,maxubslength) + breakchar; seg = seg.slice (maxubslength); } } } outStr += outseg; } segStart = pos + 1; } if (found) { outStr += c; } pos++; } }, 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 = { Base64: { // private property _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", // public method for encoding encode : function (input) { var output = "", chr1, chr2, chr3, enc1, enc2, enc3, enc4, i = 0; input = FIRSTCLASS.lang.Base64._utf8_encode(input); while (i < input.length) { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); } return output; }, // public method for decoding decode : function (input) { var output = "", chr1, chr2, chr3, enc1, enc2, enc3, enc4, i = 0; input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); while (i < input.length) { enc1 = this._keyStr.indexOf(input.charAt(i++)); enc2 = this._keyStr.indexOf(input.charAt(i++)); enc3 = this._keyStr.indexOf(input.charAt(i++)); enc4 = this._keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if (enc3 !== 64) { output = output + String.fromCharCode(chr2); } if (enc4 !== 64) { output = output + String.fromCharCode(chr3); } } output = FIRSTCLASS.lang.Base64._utf8_decode(output); return output; }, // private method for UTF-8 encoding _utf8_encode : function (string) { string = string.replace(/\r\n/g, "\n"); var utftext = "", c, n; for (n = 0; n < string.length; n++) { c = string.charCodeAt(n); if (c < 128) { utftext += String.fromCharCode(c); } else if ((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; }, // private method for UTF-8 decoding _utf8_decode : function (utftext) { var string = "", i = 0, c = 0, c1 = 0, c2 = 0, c3; while (i < utftext.length) { c = utftext.charCodeAt(i); if (c < 128) { string += String.fromCharCode(c); i++; } else if ((c > 191) && (c < 224)) { c2 = utftext.charCodeAt(i + 1); string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); i += 2; } else { c2 = utftext.charCodeAt(i + 1); c3 = utftext.charCodeAt(i + 2); string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); i += 3; } } return string; } }, fcTimeToDate: function (satime) { var hours, minutes, sign, UNIXTOMAC, date; if (typeof satime === "string") { satime = parseInt(satime, 10); } if (typeof FIRSTCLASS.session.timezone === "string") { hours = parseInt(FIRSTCLASS.session.timezone.substr(1, 2), 10); minutes = parseInt(FIRSTCLASS.session.timezone.substr(3, 2), 10); sign = FIRSTCLASS.session.timezone.substr(0, 1) + "1"; FIRSTCLASS.session.timezone = (hours * 60 + minutes) * sign; } satime -= (FIRSTCLASS.session.timezone*60); UNIXTOMAC = ((60 * 60 * 24 * 365 * 66) + (60 * 60 * 24 * 17)); date = new Date(); // javascript epoch starts jan 1, 1970 // sa epoch starts Jan 1, 1904 if (satime === 0 || satime < UNIXTOMAC) { return false; } else { date.setTime((satime - UNIXTOMAC) * 1000); } return date; }, dateToFCTime: function (date) { var UNIXTOMAC = ((60 * 60 * 24 * 365 * 66) + (60 * 60 * 24 * 17)), ms = date.getTime(), satime; // javascript epoch starts jan 1, 1970 // sa epoch starts Jan 1, 1904 satime = (ms / 1000) + UNIXTOMAC; return satime; }, 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="@", dot=".", lat=str.indexOf(at), lstr=str.length, 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, charcode = 0, c; if (typeof str === "string") { for (c = 0; c < str.length; c++) { len += FIRSTCLASS.lang.charLenUTF8(str.charCodeAt(c)); } } return len; }, strTruncUTF8: function (str, maxBytes) { var result = "", bLen = 0, c; for (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 = "", dotPos = inName.lastIndexOf("."), tildePos, maxBase, idx; if (dotPos >= 0) { name = inName.slice(0,dotPos); ext = inName.slice(dotPos); } else { name = inName; } tildePos = name.lastIndexOf("~"); if ((tildePos >= 0) && (name.length <= (tildePos + 3))) { idx = 0 + name.slice(tildePos + 1); if (!isNaN(idx)) { mungeIdx = idx; name = name.slice(0, tildePos); } } 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 = "", dotPos = inName.lastIndexOf("."), tildePos, maxBase, idx; if (dotPos >= 0) { name = inName.slice(0,dotPos); ext = inName.slice(dotPos); } else { name = inName; } tildePos = name.lastIndexOf("~"); if ((tildePos >= 0) && (name.length <= (tildePos + 3))) { idx = 0 + name.slice(tildePos + 1); if (!isNaN(idx)) { mungeIdx = idx; name = name.slice(0, tildePos); } } 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 = "", dotPos = inName.lastIndexOf("."); if (dotPos >= 0) { name = inName.slice(0,dotPos); } else { name = inName; } if (FIRSTCLASS.lang.strByteLenUTF8(name) > 55) { name = FIRSTCLASS.lang.strTruncUTF8(name,55); } name = name + "_th.jpg"; return name; }, 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"], hv = function (c) { return "%"+HD[Math.floor(c/16)]+HD[c%16]; }, s = "", i, c; for (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) { if (typeof u == 'undefined') return; 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:'ÿ'}, s = "", i, c; for (i=0;i0x39&&c<0x41) { r=1; } else if(c>0x5A&&c<61) { r=1; } else if(c>0x7A) { r=1; } return r; }, addslashes: function (pstr) { var str = pstr.replace(/\\/g,'\\\\'); str = str.replace(/\'/g,'\\\''); str = str.replace(/\"/g,'\\"'); str = str.replace(/\0/g,'\\0'); return str; }, stripslashes: function (pstr) { var str = pstr.replace(/\\'/g,'\''); str = str.replace(/\\"/g,'"'); str = str.replace(/\\0/g,'\0'); str = str.replace(/\\\\/g,'\\'); return str; }, binary: { AND: function (a,b){ var hb=(a>=0x80000000)&&(b>=0x80000000), 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), 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; default: return 'UNKNOWN'; } }, shallowCopyObjData: function (dst,src) { var i; for (i in src) { if (typeof src[i] !== "function") { /* case "function": break; default:*/ dst[i] = src[i]; //break; } } }, deepCopyObjData: function (dst,src) { var i; for (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, i; for (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 (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(); if (trimmed.length == 0) { return false; } else { return trimmed.lastIndexOf("?") === trimmed.length - 1; } } }; /** * The FIRSTCLASS util namespace * @class FIRSTCLASS.util */ if (!FIRSTCLASS.util) { FIRSTCLASS.util = { }; } FIRSTCLASS.util.expandHashTags = function (str) { var tagStart = -1, tagEnd = -1, inTag; var nProcessed = 0, len = str.length; var out = ''; var procSegment = function(input) { var result = input.replace(/(^|\s)#(\w+)/g, "$1#$2"); return result; }; // bail if no hash if (str.indexOf('#') < 0) { out = str; return out; } while (nProcessed < len) { // find next tag tagStart = str.indexOf('<',nProcessed); if (tagStart >= 0) { tagEnd = str.indexOf('>', tagStart); } // process tag found if any if (tagStart >= 0) { // process pre-tag text out = out + procSegment(str.slice(nProcessed, tagStart)); // process tag if (tagEnd >= tagStart) { out = out + str.slice(tagStart, tagEnd); // update position nProcessed = tagEnd; } else { // partial tag on tail, just copy to end out = out + str.slice(tagStart); nProcessed = len; } } else { // if no tag, process the tail out = out + procSegment(str.slice(nProcessed)); nProcessed = len; } } return out; }; FIRSTCLASS.util.parseParameters = function (urlstr) { var params = {}, idx = urlstr.indexOf("?"), parampart, tparams, param, i; if (idx >= 0) { parampart = urlstr.substr(idx+1); tparams = parampart.split("&"); param = ""; for (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 = "", str; 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: dtype = "M"; break; default: dtype = "M"; } 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 = {}, 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 definition.objtype = FIRSTCLASS.objTypes.confitem; break; default: definition.objtype = FIRSTCLASS.objTypes.confitem; } } 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 appType = 1, pageparts = initialPage.split("/"), subtype = 0, cid = 0, uri = "", params = FIRSTCLASS.util.parseParameters(initialPage), config = {title:"", showoncomplete: true}, canrestore = false, srch = params["srch"], tag = params["tag"], tab = params["tab"], threadcontext, potentialapp, i, testuri, rows; if (pageparts[0].indexOf("?") > 0) { pageparts[0] = pageparts[0].substr(0, pageparts[0].indexOf("?")); } switch (pageparts[0]) { case "__Search": canrestore = true; if (srch) { FIRSTCLASS.search({key: decodeURI(srch), escapedkey: srch, showoncomplete:true}); } else if (tag) { FIRSTCLASS.search({key: decodeURI(tag), escapedkey: tag, showoncomplete:true, tagsonly: false}); } //FIRSTCLASS.util.revealContents(); return; case "__Discover": canrestore = true; FIRSTCLASS.whatshot(params); //FIRSTCLASS.util.revealContents(); return; case "__RecentActivity": canrestore = true; FIRSTCLASS.authorSearch(params); return; case "__Open-User": canrestore = true; subtype = 33; if (initialPage.indexOf("Resume") > 0) { cid = parseInt(pageparts[1].substr(3), 10); config.uid = cid; uri = FIRSTCLASS.session.baseURL + initialPage; appType = -104; break; } if (pageparts[1].indexOf("CID") === 0) { cid = parseInt(pageparts[1].substr(3), 10); 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), 10); 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 (i in FIRSTCLASS.session.contentHistory) { 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(tab, true, false, true); } else { if (threadcontext.threadid && threadcontext.messageid) { potentialapp.app.getCommunity().navToItem(threadcontext.threadid, threadcontext.messageid, true); } else if (threadcontext.threadid) { potentialapp.app.getCommunity().navToItemByThread(threadcontext.threadid, true); } else { potentialapp.app.getCommunity().switchToApplication(tab, true); } } //FIRSTCLASS.util.revealContents(); return; } } config.lconfcid = cid; uri = FIRSTCLASS.session.baseURL + "__Open-Conf/CID" + cid+"/"; if (FIRSTCLASS.apps.Desktop.instance._dataSource) { rows = FIRSTCLASS.apps.Desktop.instance._dataSource.query("lconfcid", "" +cid, true); for(i in rows) { if (rows[i][1].typedef.subtype == 66 && rows[i][1].typedef.objtype == 1) { uri = rows[i][1].uri; config.icon = rows[i][1].icon.uri; break; } } } if (tab) { config["tab"] = tab; } } break; case "__Open-Item": if (pageparts[1].indexOf("Mailbox") === 0) { subtype = FIRSTCLASS.subTypes.mailbox; canrestore = true; } break; case "The+Pulse": canrestore = true; subtype = FIRSTCLASS.subTypes.community; config.title = "The Pulse"; break; default: if (FIRSTCLASS.apps.Desktop.instance._dataSource) { 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 (i in FIRSTCLASS.session.contentHistory) { 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(tab, true, false, true); } else { if (threadcontext.threadid && threadcontext.messageid) { potentialapp.app.getCommunity().navToItem(threadcontext.threadid, threadcontext.messageid, true); } else if (threadcontext.threadid) { potentialapp.app.getCommunity().navToItemByThread(threadcontext.threadid, true); } else { potentialapp.app.getCommunity().switchToApplication(tab, true); } } //FIRSTCLASS.util.revealContents(); return; } } testuri = pageparts[0].replace("FV", "FAV"); 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(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, appType, 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.net.doAsyncPost({form: formcontainer.firstChild}); }; FIRSTCLASS.util.net = { createPostData: function (fields) { /* pass in array of objects with .name and .value, return obj with .postdata and .cfg */ var date = new Date(); var ro = {}; var boundStr = '--FirstClass'+date.getTime(); var post = []; var field = false, i; for (i in fields) { field = fields[i]; if (field !== null && typeof field.value !== 'undefined' && typeof field.name !== 'undefined' && field.name !== '') { if (field.type === "radio" && !field.checked) { continue; } post.push('--' + boundStr); post.push('Content-Disposition: form-data; name="' + field.name + '"'); post.push(''); post.push(field.value); } } post.push('--' + boundStr + "--\r\n"); ro.postData = post.join("\r\n"); ro.cfg = { headers: [ { name: 'Content-Type', value: 'multipart/form-data; boundary=' + boundStr} ] }; return ro; }, doAsyncPost: function (cfg) { var form = cfg.form; var isUpload = cfg.upload; var saveCB = cfg.callbacks; var action = cfg.action; var postData = cfg.postData; var useAction = action ? action : form.action; if (!isUpload) { if (useAction.indexOf("?") >= 0) { useAction += "&NoKeepAlive=1"; } else { useAction += "?NoKeepAlive=1"; } var post = FIRSTCLASS.util.net.createPostData(form.elements); if (cfg.headers) { var i; for (i in cfg.headers) { post.cfg.headers.push(cfg.headers[i]); } } return FIRSTCLASS.util.net.asyncRequest('POST', useAction, saveCB, post.postData, post.cfg); } else if (postData) { return FIRSTCLASS.util.net.asyncRequest("POST", useAction, saveCB, postData); } else { form.enctype = "multipart/form-data"; if (useAction.indexOf("?") >= 0) { useAction += "&NoKeepAlive=1"; } else { useAction += "?NoKeepAlive=1"; } return FIRSTCLASS.util.net.asyncRequest('POST', useAction, saveCB, false, {form: form, responseparameters:cfg.responseparameters}); } }, doAsyncGet: function (obj) { return FIRSTCLASS.util.net.doAsyncAction(obj, "GET"); }, doAsyncHead: function (obj) { return FIRSTCLASS.util.net.doAsyncAction(obj, "HEAD"); }, doAsyncAction: function (obj, method) { var getURL = ""; if (typeof obj == "string") { getURL = obj; } else { getURL = obj.action; } return FIRSTCLASS.util.net.asyncRequest(method, getURL, obj.callbacks, false, obj); }, // get a vKey and call the callback getVKey: function(callback) { var cb = { success: function(response) { var vkey = response.responseText; if (callback) { callback(vkey); } }, failure: function (response) { /* whoops */ } }; return FIRSTCLASS.util.net.doAsyncRequest('GET', FIRSTCLASS.session.baseURL + "__GETVKEY", cb); }, asyncRequest: function (method, uri, callback, postData, cfg) { var requestrequiresvkey = (method === "POST"); if (method === "GET" && (uri.indexOf("Delete") > 0 || uri.indexOf("Unread") > 0 || uri.indexOf("Subscribe") > 0 || uri.indexOf("__GETTICKET") > 0 || uri.indexOf("Watch=") > 0 || uri.indexOf("FormNew") > 0 || uri.indexOf("Reply") > 0 || uri.indexOf("FormSave") > 0 || uri.indexOf("Send") > 0 || uri.indexOf("Create") > 0 || uri.indexOf("Lookup") > 0 || uri.indexOf("Attach") > 0 || uri.indexOf("Embed") > 0 || uri.indexOf("LFieldID") > 0 || uri.indexOf("FCXChatCommand") > 0)) { requestrequiresvkey = true; } if (FIRSTCLASS.session.debug.debugLevel("FIRSTCLASS.util.net") > 0) { if (uri.indexOf("Templates=JS") >= 0) { uri = uri + "&DebugJSON=1"; } } if (FIRSTCLASS.session.server.requiresvkeys === 1 && requestrequiresvkey) { var vkeycallback = function(vkey) { var newuri = FIRSTCLASS.util.net._appendVKeyToGet(uri, vkey); FIRSTCLASS.util.net.doAsyncRequest(method, newuri, callback, postData, cfg); }; return FIRSTCLASS.util.net.getVKey(vkeycallback); } else { return FIRSTCLASS.util.net.doAsyncRequest(method, uri, callback, postData, cfg); } }, doAsyncRequest: function (method, uri, callback, postData, cfg) { if (FIRSTCLASS.session.debug && FIRSTCLASS.session.debug.writeMessage) { var obj = {module: "FIRSTCLASS.util.net", funcname: "doAsyncRequest", "1": {uri:uri, method: method}, "2": {postData: postData}, "10": {cfg: cfg} }; FIRSTCLASS.session.debug.writeMessage(obj); } var callbacks = { _parameters: { method: method, uri: uri, postData: postData, cfg: cfg }, fcCallbacks: callback, success: function (obj) { FIRSTCLASS.util.net._parseResponse(obj); if (this.fcCallbacks && this.fcCallbacks.success) { FIRSTCLASS.util.net._callWithScope(this.fcCallbacks, 'success', obj, this._parameters); } }, failure: function (obj) { FIRSTCLASS.util.net._parseResponse(obj); if (this.fcCallbacks && this.fcCallbacks.failure) { FIRSTCLASS.util.net._callWithScope(this.fcCallbacks, 'failure', obj, this._parameters); } }, upload: function (obj) { FIRSTCLASS.util.net._parseResponse(obj); if (this.fcCallbacks && this.fcCallbacks.upload) { FIRSTCLASS.util.net._callWithScope(this.fcCallbacks, 'upload', obj, this._parameters); } }, abort: function (obj) { FIRSTCLASS.util.net._parseResponse(obj); if (this.fcCallbacks && this.fcCallbacks.abort) { FIRSTCLASS.util.net._callWithScope(this.fcCallbacks, 'abort', obj, this._parameters); } } }; if (cfg && cfg.form) { if (YAHOO.env.ua.ie) { YAHOO.util.Connect.setForm(cfg.form, true, true); } else { YAHOO.util.Connect.setForm(cfg.form, true); } } if (cfg && cfg.headers) { YAHOO.util.Connect.resetDefaultHeaders(); YAHOO.util.Connect.setDefaultPostHeader(false); var i, hdr; for (i in cfg.headers) { hdr = cfg.headers[i]; YAHOO.util.Connect.initHeader(hdr.name, hdr.value); } } return YAHOO.util.Connect.asyncRequest(method, uri, callbacks, postData); }, _appendVKeyToGet: function (uri, vkey) { var result = uri; if (!vkey) { vkey = FIRSTCLASS.session.vkeys.pop(); } if (uri.indexOf("?") > 0) { var parts = result.split('?'); if (parts.length > 1) { parts[1] = "VKey=" + vkey + "&" + parts[1]; result = parts.join('?'); } } else { result += "?VKey=" + vkey; } return result; }, _appendVKeyToForm: function (form) { var i, vkey; for (i in form.elements) { if (form.elements[i].name == "VKey") { vkey = FIRSTCLASS.session.vkeys.pop(); form.elements[i].value = vkey; return; } } var tmp = document.createElement("div"); tmp.innerHTML = ""; if (typeof form.appendChild == "undefined") { form.elements.splice(0,0,tmp.firstChild); } else { form.insertBefore(tmp.firstChild, form.firstChild); } }, _parseResponse: function (response) { if (!response.responseJSON && response.getResponseHeader && response.getResponseHeader["Content-Type"] && response.getResponseHeader["Content-Type"].indexOf("application/json") >= 0) { response.responseJSON = this._parseJSONResponse(response.responseText); } }, _parseJSONResponse: function (responseText) { if (responseText) { var response = {}; try { var obj = FIRSTCLASS.lang.JSON.parse(responseText); response = obj; } catch (e) { response = false; } return response; } }, _callWithScope: function (cb, funcname, param, requestparameters) { if (FIRSTCLASS.session.debug && FIRSTCLASS.session.debug.writeMessage) { var obj = {module: "FIRSTCLASS.util.net", funcname: "__callWithScope", trace: false, "1": {callback:funcname, uri:requestparameters.uri, method: requestparameters.method}, "2": {callback: funcname, requestparameters: requestparameters}, "10": {callback: funcname, response:param} }; FIRSTCLASS.session.debug.writeMessage(obj); } var scope = cb; if (cb.scope) { scope = cb.scope; } var responseparameters = {}; if (requestparameters && requestparameters.cfg && requestparameters.cfg.responseparameters) { responseparameters = requestparameters.cfg.responseparameters; } scope.__FIRSTCLASSUTILNET_FUNC_WITH_SCOPE = cb[funcname]; scope.__FIRSTCLASSUTILNET_FUNC_WITH_SCOPE(param, responseparameters); delete scope.__FIRSTCLASSUTILNET_FUNC_WITH_SCOPE; } }; FIRSTCLASS.util.submitForm = function (form, isUpload, saveCB, action) { FIRSTCLASS.util.net.doAsyncPost({form:form, upload: isUpload, callbacks: saveCB, action: action}); }; 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), 10); } 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), 10); } 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(""); theImage.innerHTML = html.join(""); } }, setTinyProfPicUrlByCid: function (theImage,cid,addDateParam, setfcattrs, fcevents, dimensions, replace, thename) { if (typeof cid == "string" && cid.indexOf("CID") === 0) { cid = parseInt(cid.substr(3), 10); } 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); } theImage.setAttribute('alt', ''); YAHOO.util.Dom.setStyle(theImage, 'height', '27px'); YAHOO.util.Dom.setStyle(theImage, 'width', '20px'); } else if (replace) { var html = []; html.push(""); theImage.innerHTML = html.join(""); } }, 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); } } } }, getTinyProfPicUrlByCid: 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_20x27.jpg?'+FIRSTCLASS.util.User.LatestImageTimestamp; } else { smallURL = FIRSTCLASS.util.User.getProfileUrlByCid(cid) + 'FCXResume/profile_20x27.jpg'; } if ((typeof useUnknown != 'undefined') && !useUnknown) { return smallURL; } else if (useTimeStamp) { return smallURL + '&BFProfPic=3'; } else { return smallURL + '?BFProfPic=3'; } }, getTinyProfPicUrlByName: function (name) { return FIRSTCLASS.util.User.getProfileUrlByName(name)+'FCXResume/profile_20x27.jpg?BFProfPic=3'; }, 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'; } 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.ui.fcbase.absolute + "/online.png"}, {str: "Busy", icon:FIRSTCLASS.session.ui.fcbase.absolute + "/online.png"}, {str: "Be Right Back", icon:FIRSTCLASS.session.ui.fcbase.absolute + "/online.png"}, {str: "Away", icon:FIRSTCLASS.session.ui.fcbase.absolute + "/online.png"}, {str: "On The Phone", icon:FIRSTCLASS.session.ui.fcbase.absolute + "/online.png"}, {str: "Out to Lunch", icon:FIRSTCLASS.session.ui.fcbase.absolute + "/online.png"}, {str: "Offline", icon:FIRSTCLASS.session.ui.fcbase.absolute + "/offline.png"} ], _status: 0, _message: "", getForm: function (formname) { var form; if (formname == "buddy") { if (!FIRSTCLASS.util.BuddyList._buddyForm) { FIRSTCLASS.util.BuddyList._buddyForm = document.createElement("FORM"); 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"); 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 = ''; FIRSTCLASS.util.net.doAsyncPost({form:form}); }, addBuddy: function (name, cid,callback) { if (typeof cid == 'undefined') { FIRSTCLASS.util.net.doAsyncGet({action:FIRSTCLASS.session.baseURL + '__Open-User/'+name+'/__SharedDocuments/?Subscribe=1',callbacks:callback}); } else { var cidstr = cid; if (typeof cid == "string" && cid.indexOf("CID") === 0) { cidstr = cid; } else { cidstr = "CID" + cid; } FIRSTCLASS.util.net.doAsyncGet({action:FIRSTCLASS.session.baseURL + '__Open-User/'+cidstr+'/__SharedDocuments/?Subscribe=1',callbacks: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); var i, arow; for (i in results) { 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); var i, arow; for (i in results) { 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; }, getBuddies: function () { var buddies = []; if (FIRSTCLASS.util.BuddyList._dataSource && FIRSTCLASS.util.BuddyList._dataSource._data && FIRSTCLASS.util.BuddyList._dataSource._data.records) { var i, row; for (i in FIRSTCLASS.util.BuddyList._dataSource._data.records) { row = FIRSTCLASS.util.BuddyList._dataSource._data.records[i]; if (row.typedef.subtype == FIRSTCLASS.subTypes.profile) { buddies.push(row); } } } return buddies; }, getBuddyStats: function () { var buddies = this.getBuddies(); var ocount = 0, acount = 0, i; for (i in buddies) { if (buddies[i].status.alias) { if (buddies[i].online) { ocount++; } if (!buddies[i].status.deleted) { acount++; } } } return {total: acount, online: ocount}; } }; } /** * 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", SendIM: "__IM/__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, groupProfile: -104, 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, applicationfolder: 69, workflowfolder: 70 }; FIRSTCLASS.formids = { message: 141, filewrapper: 20503 }; FIRSTCLASS.initializeLookupTables = function() { var i; FIRSTCLASS.objTypeLookup = {}; for (i in FIRSTCLASS.objTypes) { FIRSTCLASS.objTypeLookup[FIRSTCLASS.objTypes[i]] = i; } FIRSTCLASS.subTypeLookup = {}; for (i in FIRSTCLASS.subTypes) { FIRSTCLASS.subTypeLookup[FIRSTCLASS.subTypes[i]] = i; } FIRSTCLASS.formIDLookup = {}; for (i in FIRSTCLASS.formIDs) { FIRSTCLASS.formIDLookup[FIRSTCLASS.formIDs[i]] = i; } }; FIRSTCLASS.initializeLookupTables(); FIRSTCLASS.statusMask = { base: { unread: 0x8000, urgent: 0x4000, sent: 0x2000, deleted: 0x1000, outgoing: 0x0800, protect: 0x0400, unapproved: 0x0200, moved: 0x0100, autoopen: 0x0080, addressed: 0x0040, attachments: 0x0020, subscribed: 0x0010, replicated: 0x0008, partial: 0x0004, urldoc: 0x0002, voice: 0x0001 }, extended: { frompra: 0x80000000, canundelete: 0x40000000, completeheader: 0x20000000, readonly: 0x10000000, permstationery: 0x08000000, itemisnew: 0x04000000, fixed: 0x02000000, ofrompra: 0x01000000, view: 0x00F00000, backversion: 0x00080000 } }; 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); } }; // 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.session.fcbase + '/images/unknownUser_50x67.png'; }, largeProfileImageLoadFailed: function() { this.src = FIRSTCLASS.session.templatebase + '/' + FIRSTCLASS.session.fcbase + '/images/unknownUser_135x180.png'; } }, /** * the current set of instantiated widgets * * @property widgets * @type Object */ widgets: { _autoexpandWidgets: [], autoexpand: function(textarea) { var __minHeight, paddingtop, paddingbottom, a, dummy_id, div, dummy, __lineHeight, cfg; if (!FIRSTCLASS.ui.widgets._autoexpandWidgets[textarea.id]) { __minHeight = textarea.offsetHeight; paddingtop = YAHOO.util.Dom.getStyle(textarea, 'padding-top').replace("px", ""); if (!paddingtop) { paddingtop = 0; } paddingtop = parseInt(paddingtop, 10); paddingbottom = YAHOO.util.Dom.getStyle(textarea, 'padding-bottom').replace("px", ""); if (!paddingbottom) { paddingbottom = 0; } paddingbottom = parseInt(paddingbottom, 10); __minHeight = __minHeight - (paddingtop + paddingbottom); a = parseInt(YAHOO.util.Dom.getStyle(textarea, 'min-height'), 10); if (a > 0) { __minHeight = a; } // adjust the textarea textarea.style.overflow = 'hidden'; textarea.style.overflowX = 'auto'; // set the width and height to the correct values textarea.style.width = textarea.offsetWidth + 'px'; textarea.style.height = YAHOO.util.Dom.getStyle(textarea, 'height'); dummy_id = Math.floor(Math.random() * 99999) + '_dummy_' + textarea.id; div = document.createElement('div'); div.setAttribute('id', dummy_id); document.body.appendChild(div); dummy = document.getElementById(dummy_id); // match the new elements style to the textarea YAHOO.util.Dom.setStyle(dummy, 'font-family', YAHOO.util.Dom.getStyle(textarea, 'font-family')); YAHOO.util.Dom.setStyle(dummy, 'font-weight', YAHOO.util.Dom.getStyle(textarea, 'font-weight')); YAHOO.util.Dom.setStyle(dummy, 'font-size', YAHOO.util.Dom.getStyle(textarea, 'font-size')); YAHOO.util.Dom.setStyle(dummy, 'width', textarea.offsetWidth + 'px'); YAHOO.util.Dom.setStyle(dummy, 'max-width', textarea.offsetWidth + 'px'); YAHOO.util.Dom.setStyle(dummy, 'padding', YAHOO.util.Dom.getStyle(textarea, 'padding') + 'px'); YAHOO.util.Dom.setStyle(dummy, 'margin', YAHOO.util.Dom.getStyle(textarea, 'margin') + 'px'); YAHOO.util.Dom.setStyle(dummy, 'word-wrap', 'break-word'); /*YAHOO.util.Dom.setStyle(dummy, 'overflow-x', 'auto');*/ // hide the created div away YAHOO.util.Dom.setStyle(dummy, 'position', 'absolute'); YAHOO.util.Dom.setStyle(dummy, 'top', '0px'); YAHOO.util.Dom.setStyle(dummy, 'left', '-9999px'); dummy.innerHTML = ' 42'; __lineHeight = dummy.offsetHeight; cfg = { minHeight: __minHeight, dummy: dummy, lineHeight: __lineHeight, textarea: textarea, padding: (paddingtop + paddingbottom) }; FIRSTCLASS.ui.widgets._autoexpandWidgets[textarea.id] = cfg; if (typeof cfg.hasparentbox == "undefined") { cfg.hasparentbox = YAHOO.util.Dom.hasClass(textarea.parentNode, 'tm'); } } cfg = FIRSTCLASS.ui.widgets._autoexpandWidgets[textarea.id]; var html = textarea.value; html = html.replace(/\n/g, '
new'); var txheight = 0; if (cfg.dummy.innerHTML != html) { cfg.dummy.innerHTML = html; var __dummyHeight = cfg.dummy.offsetHeight; var __textareaHeight = textarea.offsetHeight - cfg.padding; if (__textareaHeight != __dummyHeight) { if (__dummyHeight > cfg.minHeight) { if (YAHOO.env.ua.ie > 0) { txheight = __dummyHeight; } else { txheight = (__dummyHeight + cfg.lineHeight); } } else { txheight = cfg.minHeight; } } if (txheight !== 0) { textarea.style.height = txheight + 'px'; if (cfg.hasparentbox && YAHOO.env.ua.ie > 0) { if (txheight === 0) { txheight = ""; } else { txheight = txheight + "px"; } YAHOO.util.Dom.setStyle(textarea.parentNode.parentNode.parentNode.childNodes[1].childNodes[0], 'height', txheight); YAHOO.util.Dom.setStyle(textarea.parentNode.parentNode.parentNode.childNodes[1].childNodes[1], 'height', txheight); } } } }, 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); }, buildTightContentBox: 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('tm', tmp); FIRSTCLASS.ui.Dom.reparentNode(content, middle); return tmp; }; FIRSTCLASS.ui.widgets.buildTightContentBox = 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("
"); 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('tm', box); var child = middle.firstChild; if (!child) { middle.innerHTML = "
"; } 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.net.doAsyncPost({ form: config.domElement.firstChild, upload: true, callbacks: 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.session.fcbase + '/images/ButtonON' + hoverBtn + '_left.png'; YAHOO.util.Dom.setStyle(this.firstChild.nextSibling, 'background-image', 'url(' + FIRSTCLASS.session.templatebase + '/' + FIRSTCLASS.session.fcbase + '/images/ButtonON' + hoverBtn + '_mid.png)'); this.lastChild.firstChild.src = FIRSTCLASS.session.templatebase + '/' + FIRSTCLASS.session.fcbase + '/images/ButtonON' + hoverBtn + '_right.png'; }); YAHOO.util.Event.addListener(btnElement, "mouseout", function() { this.firstChild.firstChild.src = FIRSTCLASS.session.templatebase + '/' + FIRSTCLASS.session.fcbase + '/images/ButtonOUTLINE_left.png'; YAHOO.util.Dom.setStyle(this.firstChild.nextSibling, 'background-image', ''); this.lastChild.firstChild.src = FIRSTCLASS.session.templatebase + '/' + FIRSTCLASS.session.fcbase + '/images/ButtonOUTLINE_right.png'; }); }, flashButton: function(btnElement) { var that = this; if (this._shine & 1) { btnElement.firstChild.firstChild.src = FIRSTCLASS.session.templatebase + '/' + FIRSTCLASS.session.fcbase + '/images/ButtonOUTLINE_left.png'; YAHOO.util.Dom.setStyle(btnElement.firstChild.nextSibling, 'background-image', ''); btnElement.lastChild.firstChild.src = FIRSTCLASS.session.templatebase + '/' + FIRSTCLASS.session.fcbase + '/images/ButtonOUTLINE_right.png'; } else { btnElement.firstChild.firstChild.src = FIRSTCLASS.session.templatebase + '/' + FIRSTCLASS.session.fcbase + '/images/ButtonONdark_left.png'; YAHOO.util.Dom.setStyle(btnElement.firstChild.nextSibling, 'background-image', 'url(' + FIRSTCLASS.session.templatebase + '/' + FIRSTCLASS.session.fcbase + '/images/ButtonONdark_mid.png)'); btnElement.lastChild.firstChild.src = FIRSTCLASS.session.templatebase + '/' + FIRSTCLASS.session.fcbase + '/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"); } }); } }, setupChatButton: function(row) { var that = this; var dochat = document.getElementById('fcMiniProfileDoChat'); if (dochat != null) { that.setupForGlow(dochat, true); YAHOO.util.Event.addListener(dochat, 'click', function() { FIRSTCLASS.apps.Global.chat.openChat(row.uid, row.name); FIRSTCLASS.ui.MiniProfile.hideBoxNow(); }); } return dochat; }, showMiniProfile: function(domElement, user, callbacks, showoncomplete, showFollowBtn, neverHover, showtoolbar) { var that = this; var handleProfileError = function(response) { FIRSTCLASS.ui.MiniProfile.hideBoxNow(); if (callbacks && callbacks.profileFail) { callbacks.profileFail(user.name); } return; } var handleProfile = function(response) { if ((user.uid <= 0) || (CIDOfUser != user.uid)) { // alert("CID <=0 --- Please let DEV know about this"); return; } if ((YAHOO.env.ua.ie) && ((response.responseText.indexOf("ERR404") >= 0) || (response.responseText.indexOf("ERR403") >= 0))) { handleProfileError(response); return; } var tempContainer = document.createElement("div"); tempContainer.innerHTML = response.responseText; domElement.innerHTML = FIRSTCLASS.ui.Dom.getChildByIdName('popUp', tempContainer).innerHTML; var ministatMsg = FIRSTCLASS.ui.Dom.getChildByIdName('statusMsg', domElement); FIRSTCLASS.ui.Dom.setInnerHTML(FIRSTCLASS.lang.mlesc(ministatMsg, FIRSTCLASS.util.expandHashTags(ministatMsg.innerHTML.parseURLS(23, 30)))); var timeDiv = FIRSTCLASS.ui.Dom.getChildByIdName('lastmsgtime', domElement); if (timeDiv) { var statTime = parseInt(timeDiv.innerHTML, 10); if (!isNaN(statTime) && (statTime !== 0)) { timeDiv.innerHTML = "(" + FIRSTCLASS.util.Date.getFriendlyDateTimeString(FIRSTCLASS.lang.fcTimeToDate(statTime)) + ")"; } } 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') == null)) { 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) { var i; for (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 (FIRSTCLASS.ui.MiniProfile.overlayBox && 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(); } }; CIDOfUser = user.uid; var theURL = FIRSTCLASS.util.User.getProfileUrlByCid(CIDOfUser) + "FCXResume?Templates=Popup"; if (typeof showtoolbar == "undefined" || showtoolbar) { theURL += "&ShowToolbar=1"; } if (FIRSTCLASS.util.BuddyList.isBuddy(CIDOfUser)) { theURL += "&IsBuddy=1"; } if (user && user.name) { theURL += "&username=" + user.name; } if (CIDOfUser == FIRSTCLASS.session.user.cid) { theURL += "&" + FIRSTCLASS.util.User.LatestImageTimestamp; } var callback = { success: handleProfile, failure: handleProfileError }; var request = FIRSTCLASS.util.net.doAsyncGet({ action: theURL, callbacks: 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; } }, setPageRSSFeed: function(obj) { /* var rssfeed = $('RSSFeedElement'); if (rssfeed) { rssfeed.parentNode.removeChild(rssfeed); } rssfeed = document.createElement("link"); var parent = document.getElementsByTagName("head").item(0); rssfeed.id = 'RSSFeedElement'; rssfeed.href = obj.href; rssfeed.atitle = obj.title; rssfeed.type = "application/rss+xml"; rssfeed.rel = "alternate"; parent.appendChild(rssfeed); */ }, clearPageRSSFeed: function() { var rssfeed = $('RSSFeedElement'); if (rssfeed) { rssfeed.parentNode.removeChild(rssfeed); } }, Dom: { updateViewportBounds: function() { if (!this._viewportBounds) { FIRSTCLASS.ui.Dom.onViewportTimeout(); } else { if (this.viewportTimeout) { window.clearTimeout(this.viewportTimeout); } this.viewportTimeout = FIRSTCLASS.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(); } if (FIRSTCLASS.apps.Global) { FIRSTCLASS.apps.Global.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), child, cfcid = "", tmpchild; child = firstChild; while (child) { cfcid = child.getAttribute('fcid'); if (cfcid && cfcid == fcid) { return child; } child = YAHOO.util.Dom.getNextSibling(child); } child = firstChild; while (child) { tmpchild = FIRSTCLASS.ui.Dom.getChildByFCID(fcid, child); if (tmpchild) { return tmpchild; } child = YAHOO.util.Dom.getNextSibling(child); } return null; }, getChildrenByClassName: function(classname, node) { var children = []; var firstChild = YAHOO.util.Dom.getFirstChild(node), child, tmpchild; child = firstChild; while (child) { if (YAHOO.util.Dom.hasClass(child, classname)) { children.push(child); } child = YAHOO.util.Dom.getNextSibling(child); } child = firstChild; while (child) { tmpchildren = FIRSTCLASS.ui.Dom.getChildrenByClassName(classname, child); if (tmpchildren) { var i; for (i in tmpchildren) { children.push(tmpchildren[i]); } } child = YAHOO.util.Dom.getNextSibling(child); } if (children.length > 0) { return children; } return null; }, getChildByClassName: function(classname, node, depth) { var firstChild = YAHOO.util.Dom.getFirstChild(node), child, tmpchild; child = firstChild; while (child) { if (YAHOO.util.Dom.hasClass(child, classname)) { return child; } child = YAHOO.util.Dom.getNextSibling(child); } child = firstChild; while (child) { tmpchild = FIRSTCLASS.ui.Dom.getChildByClassName(classname, child); if (tmpchild) { return tmpchild; } child = YAHOO.util.Dom.getNextSibling(child); } return null; }, getChildByTagName: function(tagname, node, depth) { var firstChild = YAHOO.util.Dom.getFirstChild(node), child, tmpchild; child = firstChild; while (child) { if (child.tagName && child.tagName.toUpperCase() == tagname.toUpperCase()) { return child; } child = YAHOO.util.Dom.getNextSibling(child); } child = firstChild; while (child) { tmpchild = FIRSTCLASS.ui.Dom.getChildByTagName(tagname, 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]; child, tmpchild; child = firstChild; while (child) { if ((typeof child.id !== "undefined") && (child.id == idname)) { return child; } //child = child.nextSibling;// child = YAHOO.util.Dom.getNextSibling(child); } child = firstChild; while (child) { 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 = FIRSTCLASS.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(); } else if (FIRSTCLASS.session.ui.experimental && typeof FIRSTCLASS.session.getActiveApplication().quickFilter != "undefined") { FIRSTCLASS.session.getActiveApplication().quickFilter(input.value); } 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"; 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"); FIRSTCLASS.util.net.doAsyncPost({ action: url, postData: postData, callbacks: { success: function(o) { input.value = "Send Succeeded"; input.disabled = false; }, failure: function(o) { input.value = "Send Failed"; input.disabled = false; } } }); } 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 = [], i, tags, legacymode, tag, ts, thetag, item; if (stags != "") { legacymode = false; 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 (i in tags) { tag = tags[i]; ts = tag.split(FIRSTCLASS.ui.tags.defines.countdelimiter); if (legacymode) { ts = tag.split(FIRSTCLASS.ui.tags.defines.legacy.countdelimiter); } if (ts.length >= 1) { thetag = ts[0]; if (thetag.indexOf(""" >= 0)) { thetag = thetag.replace(/"/g, ""); } ts[0] = thetag; } item = { "tag": ts[0], "weight": 1 }; if (ts.length == 2) { item = { "tag": ts[0], "weight": parseInt(ts[1], 10) }; } for (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, max = -1, avg = 0, i, n, range; for (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; } range = (max - min) / 6; for (i in atags) { 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(FIRSTCLASS.lang.mlesc(cfg.tag.preprocess({ maxstr: 23, breakchar: "​" })).replace(/&#x200b;/g, "​")); if (typeof cfg.clickable == "undefined" || cfg.clickable) { html.push(""); } html.push(""); return html.join(""); }; FIRSTCLASS.ui.generateCloud = function(atags, makefunctext) { var cloud = [], i; calculateTagWeights(atags); for (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 = [], len = 0, dup, 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, i; for (i in atags) { if (atags[i].weight > fRange) { fRange = atags[i].weight; } } for (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) { 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; } } if (tagList && tagList.length > 1) { tagList.sort(compareTags); var i; for (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); var i; for (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 = [], i; for (i in cloud1) { outcloud.push(cloud1[i]); } for (i in cloud2) { var found = false, j; for (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 = [], i; for (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 FIRSTCLASS.util.net.doAsyncGet({ action: FIRSTCLASS.session.templatebase + "/" + FIRSTCLASS.session.fcbase + "/resources/skins/" + string + "/skin.pjs?JSON=2", callbacks: { success: function(response) { var obj = {}; var html = []; try { obj = response.responseJSON; if (!obj) { obj = FIRSTCLASS.lang.JSON.parse(response.responseText); } if (obj && obj.images) { var loaded = []; var images = [], i; for (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, i; for (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 = FIRSTCLASS.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(" "), i; for (i in bodycnames) { var cname = bodycnames[i]; if (typeof cname == "string" && cname.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.ui.fcbase.absolute + "/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: { _currentEmbedDiv: false, resetEmbed: function() { FIRSTCLASS.ui.embeds._currentEmbedDiv = false; }, clearEmbed: function() { var el = FIRSTCLASS.ui.embeds._currentEmbedDiv; if (el) { el.innerHTML = ""; YAHOO.util.Dom.removeClass(el, 'fcEmbed-active'); YAHOO.util.Dom.addClass(el, 'fcEmbed'); } FIRSTCLASS.ui.embeds.resetEmbed(); }, handleClick: function(fcevent, itemurl) { var attrs = fcevent.fcattrs.split(";"); var w = attrs[1] - 0; var h = attrs[2] - 0; w += 75; h += 50; FIRSTCLASS.ui.embeds._currentEmbedDiv = fcevent.target; 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, useShim: true }); } } }; FIRSTCLASS.ui.ToolbarPopup = { width: 450, height: 250, zindex: 2000, popupShown: false, theLastBtn: null, currentRgn: null, initBox: function(width,height,rgn) { if (!width) { width = this.width; } width += 36; // leave room for corners/edges if (height) { height = this.height; } height += 23; // leave room for corners/edges if (!this.overlay) { this.overlay = new YAHOO.widget.Overlay("fcTBPopupOverlay", { visible:false, //width: width + 'px', //height: height + 'px', zIndex: this.zindex }); } this.domElement = document.createElement("DIV"); this.domElement.id = 'fcToolbarPopup'; this.overlayBox = $("fcTBPopupOverlay"); var html = []; html.push(""); html.push(""); html.push("
"); this.domElement.innerHTML = html.join(""); this.overlay.setBody(this.domElement); this.overlay.render(document.body); if (rgn.left + width > document.width) rgn.left = document.width - width; this.currentRgn = rgn; this.overlay.cfg.setProperty("xy",[rgn.left,rgn.bottom+3]); }, onDisplay : function () { FIRSTCLASS.ui.ToolbarPopup.ensureOnscreen(); }, ensureOnscreen: function () { var doctop = YAHOO.util.Dom.getDocumentScrollTop(); var viewport = FIRSTCLASS.ui.Dom.getViewportBounds(); if (this.currentRgn.top + this.domElement.clientHeight > viewport.ht+doctop) { this.currentRgn.top = viewport.ht+doctop - this.domElement.clientHeight; this.overlay.cfg.setProperty("xy",[this.currentRgn.left,this.currentRgn.top]); } }, showFromToolbar: function (theButton,buttoncfg,evt) { var rgn = YAHOO.util.Region.getRegion(YAHOO.util.Event.getTarget(evt)); var cb = buttoncfg.popup.callbacks; if (evt) { YAHOO.util.Event.stopPropagation(evt); } if (this.theLastBtn != null) { this.closePopup(this.theLastBtn,buttoncfg,evt); } this.theLastBtn = theButton; YAHOO.util.Dom.addClass(theButton,"fcTBPoppedUp"); YAHOO.util.Dom.addClass(theButton.lastChild, "fcTBPopUpCloser"); YAHOO.util.Dom.removeClass(theButton.lastChild, "fcTBPopUpOpener"); this.initBox(buttoncfg.popup.width, buttoncfg.popup.height,rgn); if (cb && cb.onRender) { cb.onRender(evt, document.getElementById('popupContent')); this.ensureOnscreen(); } if (cb && cb.preDisplay) { cb.preDisplay(); } this.overlay.show(); this.popupShown = true; if (cb && cb.onDisplay) { cb.onDisplay(); } return this; }, closePopup: function (theButton, buttoncfg, evt) { if (this.popupShown) { this.popupShown = false; var that = this; if (!theButton) { theButton = this.theLastBtn; this.theLastBtn = null; } if (theButton) { YAHOO.util.Dom.removeClass(theButton,"fcTBPoppedUp"); YAHOO.util.Dom.removeClass(theButton.lastChild, "fcTBPopUpCloser"); YAHOO.util.Dom.addClass(theButton.lastChild, "fcTBPopUpOpener"); } if (FIRSTCLASS.ui.ToolbarPopup.overlay) { if (buttoncfg && buttoncfg.popup.callbacks && buttoncfg.popup.callbacks.onClose) { buttoncfg.popup.callbacks.onClose(); } this.overlay.hide(); } } } }; FIRSTCLASS.ui.MiniProfile = { width: 450, height: 250, overlap: 5, shown: false, timeout: 800, timeoutToHide: 400, showTimeout: 0, hideTimeout: 0, mouseHasLeft: false, zindex: 3000, anchorElement: null, userinfo: null, lastClientX: -1, lastClientY: -1, initBox: function(width, height) { if (!width) { width = this.width; } if (!height) { height = this.height; } if (!this.overlay) { this.overlay = new YAHOO.widget.Overlay("fcMiniProfileOverlay", { visible:false, // width: width + 'px', // height: height + 'px', zIndex: this.zindex }); this.domElement = document.createElement("div"); this.domElement.id = 'fcMiniProfilePopup'; this.overlay.setBody(this.domElement); this.overlay.render(document.body); this.overlayBox = $("fcMiniProfileOverlay"); } else { YAHOO.util.Dom.setStyle(this.overlayBox,'height', height + 'px'); YAHOO.util.Dom.setStyle(this.overlayBox.firstChild,'height', height + 'px'); YAHOO.util.Dom.setStyle(this.overlayBox,'width', width + 'px'); YAHOO.util.Dom.setStyle(this.overlayBox.firstChild,'width', width + 'px'); } }, show: function() { var anchorElement = this.anchorElement; var 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) { this.initBox(); 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(); if (this.overlay) { this.overlay.hideMacGeckoScrollbars(); } }, processBox: function () { if (!this.domElement) { return; } 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 = ""; } }, clearTimeouts: function () { if (this.showTimeout) { window.clearTimeout(this.showTimeout); this.showTimeout = 0; } if (this.hideTimeout) { window.clearTimeout(this.hideTimeout); this.hideTimeout = 0; } }, 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 = FIRSTCLASS.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 = FIRSTCLASS.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; this.shown = false; }, dispatchShow: function (_anchorElement,_userinfo) { this.anchorElement = _anchorElement; this.userinfo = _userinfo; this.url = location.href; this.showTimeout = FIRSTCLASS.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 = FIRSTCLASS.setTimeout(this.showBox,FIRSTCLASS.ui.MiniProfile.timeout); } } }, mouseout: function(event,fcevent) { var ptInDialog = true, bdOrg = false, bdRect = false; if (this.overlay && this.overlay.body) { bdOrg = YAHOO.util.Dom.getXY(this.overlay.body); bdRect = { top: bdOrg[1], left: bdOrg[0], bottom: bdOrg[1] + this.overlay.body.offsetHeight, right: bdOrg[0] + this.overlay.body.offsetWidth }; if ((event.clientX < bdRect.left) || (event.clientX > bdRect.right) || (event.clientY < bdRect.top) || (event.clientY > bdRect.bottom)) { ptInDialog = false; } } // only do parentage test if point is inside if (ptInDialog) { if (fcevent.target.parentNode && fcevent.target.parentNode.getAttribute) { var fcidAttr = fcevent.target.parentNode.getAttribute('fcid'); if ((fcidAttr == 'user') || (fcidAttr == 'dofollow') || (fcidAttr == 'dochat') || (fcidAttr == 'authorsearch')) { return true; } } } FIRSTCLASS.ui.MiniProfile.mouseHasLeft = true; if (this.overlay && this.shown) { this.hideTimeout = FIRSTCLASS.setTimeout(FIRSTCLASS.ui.MiniProfile.hideBoxNow, this.timeoutToHide); } if (this.showTimeout) { window.clearTimeout(this.showTimeout); this.showTimeout = 0; } return false; } }; /** Toolbar widget * Configuration is: * domElement(obj): element toolbar installs into * vertical(bool): toolbar is displayed vertically * ends (str): sausage end elements to display; 'left', 'right', 'none' or 'both' (default) * buttons []: array of button definitions of the form: * id(str) button id * label(str) button label * priv(num) enabling bitmask from ACL * fcid(str) fcid for std event handler * fcattrs(str) fcattrs for std event handler * click(fn) click handler * condition(fn) condition function to control button presence * popup (obj) definition of menu popup * width(num) desired width of popup * height(num) desired height of popup * callbacks(obj) - pop callbacks * onRender(evt, el) - render content into element based on activating event * preDisplay() - hook prior to display * onDisplay() - hook after display * onClose() - hook prior to popup close * type(str) one of various special button types **/ FIRSTCLASS.ui.toolBar = function(config) { var hover = null, buttons = [], that = this, showLeft = !config.ends || config.ends == 'left' || config.ends == 'both', showRight = !config.ends || config.ends == 'right' || config.ends == 'both'; 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("
  
"); config.domElement.innerHTML = html.join(""); this._domEl = FIRSTCLASS.ui.Dom.getChildByClassName('fcToolBarC',config.domElement); } var makeButton = function (theButton, buttoncfg, acl) { 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 || buttoncfg.popup) { YAHOO.util.Event.purgeElement(theButton, true); if (buttoncfg.click) { YAHOO.util.Event.addListener(theButton, "click", function(evt){ buttoncfg.click(evt, that.parameter); }); } if (buttoncfg.popup) { buttoncfg.popup._isOpen = false; YAHOO.util.Event.addListener(theButton, "click", function(evt) { if (buttoncfg.popup._isOpen) { buttoncfg.popup._isOpen = false; FIRSTCLASS.ui.ToolbarPopup.closePopup(theButton,buttoncfg,evt); } else { buttoncfg.popup._isOpen = true; FIRSTCLASS.ui.ToolbarPopup.showFromToolbar(theButton,buttoncfg,evt); } }); } } }; this.addButton = function (buttoncfg) { var theButton = document.createElement("div"); if (this._domEl.lastChild) { YAHOO.util.Dom.removeClass(this._domEl.lastChild, "fcToolBarLastButton"); } if (buttoncfg.isLink) { this._domEl.appendChild(theButton); } else { var theAnchor = document.createElement("a"); theAnchor.setAttribute('href','javascript:void(0);') YAHOO.util.Dom.setStyle(theAnchor,'text-decoration','none'); theAnchor.appendChild(theButton); this._domEl.appendChild(theAnchor); } /*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": case "reply": break; case "popup": YAHOO.util.Dom.addClass(theButton,"fcToolBarButton"); FIRSTCLASS.locale.setElementString(buttoncfg.label, theButton, "$content$
"); break; 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) { if (theButton.parentNode && theButton.parentNode.setAttribute) { YAHOO.util.Dom.setStyle(theButton.parentNode, "display", "none"); } } YAHOO.util.Dom.addClass(this._domEl.lastChild.firstChild, "fcToolBarLastButton"); }; this.removeButton = function (buttonid) { var buttonelem = buttons[buttonid]; if (buttonelem) { this._domEl.removeChild(buttonelem); YAHOO.util.Event.purgeElement(buttonelem); buttons[buttonid] = false; } }; this.hideButton = function (buttonid) { var buttonelem = buttons[buttonid]; if (buttonelem) { if (buttonelem.parentNode && buttonelem.parentNode.setAttribute) { YAHOO.util.Dom.setStyle(buttonelem.parentNode, "display", "none"); } YAHOO.util.Dom.removeClass(buttonelem, 'fcToolBarLastButton'); } }; this.showButton = function(buttonid,i) { var buttonelem = buttons[buttonid]; if (buttonelem) { if (buttonelem.parentNode && buttonelem.parentNode.setAttribute) { YAHOO.util.Dom.setStyle(buttonelem.parentNode, "display", ""); } if (this._lastButton !== null) { YAHOO.util.Dom.removeClass(this._lastButton, 'fcToolBarLastButton'); } YAHOO.util.Dom.addClass(buttonelem, 'fcToolBarLastButton'); this._lastButton = buttonelem; if (i && (config.buttons[i].type == 'popup')) { FIRSTCLASS.ui.ToolbarPopup.closePopup(false,config.buttons[i]); } } }; // reconfigure the toolbar, passing param to the condition handler this.reconfigure = function (param, acl) { var buttonelem, i; this._lastButton = null; for (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); if (param !== null) { this.setScreenreader(buttonelem,param,config.buttons[i].label); } } else { this.hideButton(config.buttons[i].id); } } else { this.showButton(config.buttons[i].id,i); if (param !== null) { this.setScreenreader(buttonelem,param,config.buttons[i].label); } if (config.buttons[i].customizer) { makeButton(buttonelem, config.buttons[i], acl); } } if (config.buttons[i].type == 'popup') { FIRSTCLASS.ui.ToolbarPopup.closePopup(false,config.buttons[i]); } } else { this.hideButton(config.buttons[i].id); } } this.parameter = param; }; // update label for existing button this.setButtonLabel = function (buttonid,label) { var i; for (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; } } }; this.setScreenreader = function (btn,param,label) { if (btn && btn.parentNode && btn.parentNode.setAttribute) { var subject; if ((typeof param.subject !== 'undefined') && (param.subject != "")) { subject = param.subject; } else { subject = param.col8010; } if (label.indexOf("|") >= 0) { label = label.split("|")[0]; } btn.parentNode.setAttribute('title',subject + ": " + label); } }; var button; for (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 () { if (YAHOO.env.ua.ie) { YAHOO.util.Dom.setStyle(this._domElement.parentNode, "visibility", "hidden"); YAHOO.util.Dom.setStyle(this._domElement.parentNode, "width", "0px"); YAHOO.util.Dom.setStyle(this._domElement.parentNode, "min-width", "0px"); YAHOO.util.Dom.setStyle(this._domElement.parentNode, "max-width", "0px"); YAHOO.util.Dom.setStyle(this._domElement, 'display', 'none'); } else { 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, width) { var anim, w, attributes, that, f; var fw = false; if (width) { fw = typeof width == 'number' ? width + 'px' : width; } 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, "visibility", ""); YAHOO.util.Dom.setStyle(this._domElement.parentNode, "width", ""); YAHOO.util.Dom.setStyle(this._domElement.parentNode, "min-width", "250px"); YAHOO.util.Dom.setStyle(this._domElement.parentNode, "max-width", ""); YAHOO.util.Dom.setStyle(this._domElement, 'display', ''); //AHOO.util.Dom.setStyle(this._domElement.parentNode, "display", ""); } if (animate && YAHOO.util.Anim) { w = FIRSTCLASS.ui.Dom.getViewportWidth()*0.2; if (typeof width == 'number') { w = width; } if (w < 180) { w = 180; } attributes = { width: { to: w } }; fw = w + 'px'; that = this; f = function () { YAHOO.util.Dom.setStyle(that._domElement.parentNode, 'min-width', ''); if (fw) { YAHOO.util.Dom.setStyle(that._domElement.parentNode, 'width', fw); } else { YAHOO.util.Dom.setStyle(that._domElement.parentNode, 'width', ''); } if (oncomplete) { oncomplete(); } }; 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(); } if (!anim && fw) { YAHOO.util.Dom.setStyle(this._domElement.parentNode, 'width', fw); } this._hidden = false; }; FIRSTCLASS.ui.sideBar.prototype.resetApplicationBoxContents = function () { this._appboxes = []; 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, role) { var container = this._templateBox.cloneNode(true); YAHOO.util.Dom.addClass(container, "fcSideBarContainer"); if (invisible) { YAHOO.util.Dom.setStyle(container,"display","none"); } if (role) FIRSTCLASS.locale.setElementRole(role, container.firstChild); else FIRSTCLASS.locale.setElementRole("complementary", container.firstChild); 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); 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); } if (pTitle == "") { YAHOO.util.Dom.addClass(tablehead, 'fcHidden'); } }; 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); butt.setAttribute('fcattrs', pTitle); } else { butt.href = newaction; } butt.innerHTML = atitle; } else if (typeof newaction == "object") { butt = document.createElement("div"); if (newaction.type == "combo") { var html = [""); butt.innerHTML = html.join(""); FIRSTCLASS.events.registerInput(butt.firstChild); YAHOO.util.Dom.addClass(butt,"fcHeaderDropDownButton"); } else { butt.innerHTML = newaction.defaultchoice; } } else { butt = document.createElement("div"); if (fcid) { butt.setAttribute('fcid', fcid); butt.setAttribute('fcattrs', pTitle); } 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) { var isvariable = c.isvariable; if (c.bd && c.bd.collapsed) { c.bd.oldheight = c.bd.clientHeight; YAHOO.util.Dom.setStyle(c.bd, "height", "" + "0px"); isvariable = false; } if (c.bd && !c.bd.collapsed && c.bd.oldheight) { YAHOO.util.Dom.setStyle(c.bd, "height", "" + c.bd.oldheight + "px"); delete c.bd.oldheight; } if (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, i; for (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 (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); YAHOO.util.Dom.setStyle($('fcNavBarPictureContainer'), 'width', ""); }; that.setLargeUserProfilePicture = function (height,cid,addDateParam) { var ht = height || 180; picture.height = ht; FIRSTCLASS.util.User.setLargeProfPicUrlByCid(picture,cid,addDateParam, false); YAHOO.util.Dom.setStyle($('fcNavBarPictureContainer'), 'width', ""); }; that.setProfilePicture = function (uri, height, fcid, width) { picture.src = uri; var ht = height || 67; picture.height = ht; if (fcid) { picture.setAttribute('fcid', fcid); } else { picture.setAttribute('fcid', ''); } if (width) { YAHOO.util.Dom.setStyle($('fcNavBarPictureContainer'), 'width', width+"px"); } else { YAHOO.util.Dom.setStyle($('fcNavBarPictureContainer'), 'width', ""); } }; 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"); title.innerHTML = "" + user.name+""; that.setProfileLink(user); }; that.setTitle = function(name) { YAHOO.util.Dom.setStyle(title, "cursor", "default"); title.innerHTML = name; }; 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, alwaysfocussed) { // FIXME: much more complicated than this to get this working var blankText = FIRSTCLASS.locale.desktop.emptystatus; if (alwaysfocussed) { blankText = "What's on your mind?"; } 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); } if (!alwaysfocussed) { YAHOO.util.Dom.removeClass(table, "focussed"); } }); YAHOO.util.Event.addListener(curstatus, "focus", function (evt) { var curstatus = evt.target; if (curstatus.value == blankText) { curstatus.value = ""; } else { curstatus.select(); } if (!alwaysfocussed) { YAHOO.util.Dom.addClass(table, "focussed"); } }); } if (alwaysfocussed) { YAHOO.util.Dom.addClass(table, "focussed"); } } else { bottomText.innerHTML = ""; } }; that.setProfileStatus2 = function (status, listener, alwaysfocussed) { // FIXME: much more complicated than this to get this working var blankText = FIRSTCLASS.locale.desktop.emptystatus; if (alwaysfocussed) { blankText = "What's on your mind?"; } 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); } if (!alwaysfocussed) { YAHOO.util.Dom.removeClass(table, "focussed"); } else { YAHOO.util.Dom.removeClass(table, "expanded"); } }); } if (alwaysfocussed) { 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 (typeof shout.who == "undefined") { shout.who = "the administrator"; } 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 mins = date.getMinutes(); if (mins < 10) { mins = "0" + mins; } var dstr = hrs+":"+mins+((date.getHours()>=12)?' pm':' am'); var html = ["
", "
at ", dstr, ", " + shout.who + " 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; }; // viewMapper widget - takes a map of element destinations and inserts the elements into their destinations according to a passed-in key. // // The map object is an array of objects of the form: // { element(obj) the element to be mapped // views(array) of {view_name, dest_element} pairs // } // The view mode is set by calling the selectView() function and passing the name of the selected view. // Elements with no mapping for the selected view will be stored in a member out-of-page DIV. // // The dispose() method clears the offline element. FIRSTCLASS.ui.viewMapper = function(map) { this._offlineEl = document.createElement('div'); this._viewMap = map; }; FIRSTCLASS.ui.viewMapper.prototype.selectView = function(view) { // put the components into their places for the new view var component, idx; for (idx in this._viewMap) { if (this._viewMap[idx].element) { component = this._viewMap[idx]; if (component.views[view]) { FIRSTCLASS.ui.Dom.reparentNode(component.element, component.views[view]); } else { FIRSTCLASS.ui.Dom.reparentNode(component.element, this._offlineEl); } } } }; FIRSTCLASS.ui.viewMapper.prototype.dispose = function() { this._offlineEl.innerHTML = ""; }; // 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 = "", i; for (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 instDlg; var doInstall = function () { if (YAHOO.env.ua.gecko) { var params = {}; params[FIRSTCLASS.locale.community.docs.plugin.FFName] = { URL: '/bluefield.templates/' + FIRSTCLASS.session.fcbase + '/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(); }; 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 itemUrl = ""; if (row.linkinfo && row.linkinfo.url) { itemUrl = row.linkinfo.url.substr(1); } else if (row.name) { itemUrl = FIRSTCLASS.session.domain + FIRSTCLASS.lang.ensureSlashUrl(ds.getContainerUrl()) + encodeURI(row.name); } if (itemUrl) { if (typeof URLLauncher != "undefined") { URLLauncher.dourl(itemUrl); } 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(itemUrl); } } } } } 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.timeformat; var param = date.getHours(); str = str.replace("$hours24$", "" + param); param = ((date.getHours() % 12) === 0) ? "12" : (date.getHours() % 12); str = str.replace("$hours12$", "" + param); param = date.getMinutes(); str = str.replace("$minutes$", ((param < 10)?"0":"")+param); str += date.getHours() >= 12 ? FIRSTCLASS.locale.Date.pmsuffix : FIRSTCLASS.locale.Date.amsuffix; str = FIRSTCLASS.locale.Date.at + str; //" " + (((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; }, getShortFriendlyDateTimeString: 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 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 { str = FIRSTCLASS.locale.Date.aboutminutes.replace("$minutes$", Math.ceil(diff/60)); } } else { str = Math.floor(diff/3600) + " hours ago"; } } else { str = FIRSTCLASS.util.Date.getFriendlyDateString(date); } return str; }, _pad: function(number, digits) { var str = "" + number; if (digits) { if (str.length < digits) { var pad = ""; while (pad.length < digits - str.length) { pad += "0"; } str = pad + str; } } return str; }, getShortDateTimeString: 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 out = ''; if (!(now.getMonth() == date.getMonth() && now.getYear() == date.getYear() && now.getDate() == date.getDate())) { out = date.getFullYear() + "/" + this._pad(date.getMonth()+1, 2) + "/" + this._pad(date.getDate(), 2) + " "; } out += this._pad(date.getHours(), 2) + ":" + this._pad(date.getMinutes(), 2) + ":" + this._pad(date.getSeconds(), 2); return out; } }; 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; }, // file is an image isImageFile: function (fileName) { var dot = fileName.lastIndexOf('.'), isImage = false; if (dot >= 0) { var ext = fileName.slice(dot+1).toUpperCase(); switch(ext) { case 'JPG': case 'PNG': case 'BMP': case 'GIF': case 'SVG': case 'TIFF': isImage = true; } } return isImage; } }; 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.session.fcbase + "/images/offline.png", "/" + FIRSTCLASS.session.fcbase + "/images/online.png"], init: function () { if (!this._initialized) { // this._interval = window.setInterval(this.onInterval, 500); this._initialized = true; this.updateStatus(FIRSTCLASS.session.user.cid, 1); this.generateCSS(); } }, 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, i; FIRSTCLASS.session.RuntimeCSS.removeRulesFromDom(); for (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;display:none;"); } else { rules.push("width:7px;height:7px;display:inline;padding-right:2px;"); } 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 = { _disabled: false, processEvent: function (evt, type) { var attr, attr2, events, types, depth = 0, maxdepth = 100, tmp, target = YAHOO.util.Event.getTarget(evt), rv = [], i; if (target) { attr = target.getAttribute("fcid"); attr2 = target.getAttribute("fcattrs"); events = target.getAttribute('fcevents'); if (events) { events = events.split(","); } if (attr) { types = attr.split(","); for (i in types) { attr = types[i]; rv.push({fcid: attr, fcattrs: attr2, target: target, fcevents: events}); } } else { depth = 0; maxdepth = 100; 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++; } attr = target.getAttribute("fcid"); attr2 = target.getAttribute("fcattrs"); events = target.getAttribute('fcevents'); if (events) { events = events.split(','); } if (attr) { types = attr.split(","); for (i in types) { attr = types[i]; rv.push({fcid: attr, fcattrs: attr2, target: target, wasRecursive: true, fcevents: events}); } } } } return rv; }, eventHandlers: { blur: { placeholder: function (evt, fcevent) { if (fcevent.target.value.length === 0) { fcevent.target.value = fcevent.target.getAttribute("placeholder"); } YAHOO.util.Dom.addClass(fcevent.target, 'blurred'); } }, focus: { statustext: function (evt, fcevent) { var curstatus = fcevent.target; if (curstatus.value == "What's on your mind?") { curstatus.value = ""; } else { curstatus.select(); } }, placeholder: function (evt, fcevent) { if (fcevent.target.value == fcevent.target.getAttribute("placeholder")) { fcevent.target.value = ""; } YAHOO.util.Dom.removeClass(fcevent.target, 'blurred'); } }, change: { pulsefilter: function (evt, fcevent) { var option = false; if (fcevent.target.selectedIndex) { option = fcevent.target.childNodes[fcevent.target.selectedIndex]; } else { var node = false, a; for (a in fcevent.target.childNodes) { node = fcevent.target.childNodes[a]; if (node.selected) { option = node; break; } } } FIRSTCLASS.apps.Desktop.instance.pulsecallbacks.dofilter(parseInt(option.value, 10)); } }, 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, tagsonly: false}); break; default: /* unhandled mode, or no mode at all - do nothing */ } }, community: function (event, fcevent) { var realuri = fcevent.target.getAttribute('realuri'), params, uri, rows, row; if (realuri) { params = { title: fcevent.target.getAttribute("name"), unread:fcevent.target.getAttribute("unread"), icon: fcevent.target.getAttribute("icon") }; FIRSTCLASS.loadApplication(FIRSTCLASS.session.baseURL + realuri, FIRSTCLASS.objTypes.conference, FIRSTCLASS.subTypes.community, params); } else { uri = FIRSTCLASS.lang.removeSlashUrl(fcevent.fcattrs); 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) { row = rows[0][1]; params = { title: row.name, unread:row.status.unread, icon: row.icon.uri}; if (row.lconfcid.length > 0) { params.lconfcid = parseInt(row.lconfcid, 10); } FIRSTCLASS.loadApplication(FIRSTCLASS.session.baseURL + fcevent.fcattrs, row.typedef.objtype, row.typedef.subtype, params); } } }, mailbox: function (event, fcevent) { var uri = FIRSTCLASS.lang.removeSlashUrl(fcevent.fcattrs); FIRSTCLASS.loadApplication(fcevent.fcattrs, FIRSTCLASS.objTypes.conference, FIRSTCLASS.subTypes.mailbox); }, workflowfolder: function (event, fcevent) { var uri = FIRSTCLASS.lang.removeSlashUrl(fcevent.fcattrs); FIRSTCLASS.loadApplication(fcevent.fcattrs, FIRSTCLASS.objTypes.folder, FIRSTCLASS.subTypes.workflowfolder); }, 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, 10); 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); } }, fcOrganization: function (event, fcevent) { if (FIRSTCLASS.ui.MiniProfile.showTimeout) { window.clearTimeout(FIRSTCLASS.ui.MiniProfile.showTimeout); FIRSTCLASS.ui.MiniProfile.showTimeout = false; } FIRSTCLASS.ui.MiniProfile.hideBoxNow(); var pgnumstr = fcevent.target.getAttribute("pgnum"); var pgnum = parseInt(pgnumstr, 10); var uidString = fcevent.target.getAttribute("uid"); var uid = isNaN(uidString) ? null : parseInt(uidString, 10); var url; var name = fcevent.fcattrs; var config = {name: name,editProfile:0}; var cid = "CID"+uid; url = FIRSTCLASS.session.domain + FIRSTCLASS.session.baseURL + "__Open-User/" + cid + "/__Resume?FormID=97"; config.cid = cid; config.uid = uid; config.orgHierarchy = ""; config.pgnum = pgnum; var currNode = fcevent.target; while (currNode !== null) { var thediv = document.createElement('div'); var tempNode = currNode.previousSibling; thediv.appendChild(currNode.cloneNode(true)); config.orgHierarchy = thediv.innerHTML + config.orgHierarchy; currNode = tempNode; } 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.groupProfile,0, 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 = ""; } }, chatreply: function (event, fcevent) { YAHOO.util.Event.stopEvent(event); }, chatinput: function (event, fcevent) { YAHOO.util.Event.stopEvent(event); }, dofollow: function (event, fcevent) { var theUID = fcevent.target.getAttribute('uid'); if (theUID && (theUID != "")) { if (FIRSTCLASS.util.BuddyList.isBuddy(theUID)) { FIRSTCLASS.util.BuddyList.deleteBuddy(theUID); fcevent.target.innerHTML = FIRSTCLASS.locale.profile.follow; } else { FIRSTCLASS.util.BuddyList.addBuddy(null,theUID); fcevent.target.setAttribute('fcid',""); fcevent.target.innerHTML = FIRSTCLASS.locale.profile.following; } } YAHOO.util.Event.stopEvent(event); }, dochat: function (event, fcevent) { var fcname = fcevent.target.getAttribute('fcname'); if (!fcname) { fcname = fcevent.fcattrs; } FIRSTCLASS.apps.Global.chat.openChat(fcevent.target.getAttribute('uid'), fcname); YAHOO.util.Event.stopEvent(event); FIRSTCLASS.ui.MiniProfile.hideBoxNow(); }, authorsearch: function (event, fcevent) { FIRSTCLASS.authorSearch({cid:fcevent.target.getAttribute("uid"), user: fcevent.fcattrs}); YAHOO.util.Event.stopEvent(event); FIRSTCLASS.ui.MiniProfile.hideBoxNow(); }, francais: function (event, fcevent) { YAHOO.util.Cookie.set('fcislang', 'fr', {path: "/"}); document.location = FIRSTCLASS.session.baseURL; }, inenglish: function (event, fcevent) { YAHOO.util.Cookie.set('fcislang', 'en', {path: "/"}); document.location = FIRSTCLASS.session.baseURL; }, pulsepost: function (event, fcevent) { var tg = $('pulseinput'); var status = tg.value.trim(); if (status.length > 0 && status != FIRSTCLASS.locale.pulse.prompt) { FIRSTCLASS.util.BuddyList.setMessage(status); } tg.value = ""; FIRSTCLASS.ui.widgets.autoexpand(tg); tg.blur(); }, pulsemore: function (event, fcevent) { var ds = FIRSTCLASS.apps.Desktop.instance._pulseds; ds.fetchRows(); return true; } }, mousemove: { user: function (event,fcevent) { if (FIRSTCLASS.ui.MiniProfile.mouseInside) { FIRSTCLASS.ui.MiniProfile.resetOnMove(event,fcevent); } }, dochat: function (event, fcevent) { if (FIRSTCLASS.ui.MiniProfile.mouseInside) { FIRSTCLASS.ui.MiniProfile.resetOnMove(event,fcevent); } FIRSTCLASS.ui.MiniProfile.clearTimeouts(); FIRSTCLASS.ui.MiniProfile.show(); }, authorsearch: function (event, fcevent) { if (FIRSTCLASS.ui.MiniProfile.mouseInside) { FIRSTCLASS.ui.MiniProfile.resetOnMove(event,fcevent); } FIRSTCLASS.ui.MiniProfile.clearTimeouts(); FIRSTCLASS.ui.MiniProfile.show(); } }, mouseover: { chatinput: function (event, fcevent) { FIRSTCLASS.ui.MiniProfile.clearTimeouts(); return true; }, dochat: function (event, fcevent) { FIRSTCLASS.ui.MiniProfile.clearTimeouts(); }, 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, 10); } } else if (typeof uidString == "number") { _uid = uidString; } var _name = (typeof fcevent.fcattrs == 'undefined' ? "" : fcevent.fcattrs); if (_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 = FIRSTCLASS.ui.MiniProfile.mouseout(event,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; } }, keyup: { chatreply: function (event, fcevent) { if (event.keyCode == 13 /* enter */) { /* post reply */ FIRSTCLASS.apps.Global.chat.sendReply(fcevent.fcattrs); return true; } else { FIRSTCLASS.apps.Global.chat.updateTypingIndicator(fcevent.fcattrs); } return false; }, chatinput: function (event, fcevent) { if (event.keyCode == 13 /* enter */) { /* post reply */ FIRSTCLASS.apps.Global.chat.sendIM(fcevent.fcattrs, fcevent.target.value); fcevent.target.value = ""; return true; } return false; }, autoexpand: function (event, fcevent) { FIRSTCLASS.ui.widgets.autoexpand(fcevent.target); }, pulseinput: function (event, fcevent) { if (event.keyCode == 13 /* enter */) { var status = fcevent.target.value.trim(); if (status.length > 0 && status != FIRSTCLASS.locale.pulse.prompt) { FIRSTCLASS.util.BuddyList.setMessage(status); } fcevent.target.value = ""; fcevent.target.blur(); } } } }, 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; }, disable: function () { FIRSTCLASS.events._disabled = true; }, enable: function () { FIRSTCLASS.events._disabled = false; }, handler: function (evt) { var evts, rv, e, i, handle, handlers, h; if (FIRSTCLASS.events._disabled) { return; } evts = this.processEvent(evt); rv = false; if (evts && evts.length) { for (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) { handle = false; for (i in e.fcevents) { if (evt.type == e.fcevents[i]) { handle = true; } } if (!handle) { continue; } } handlers = this.eventHandlers[evt.type]; if (handlers) { if (e.fcid) { 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; }, hfunc: function (evt) { return FIRSTCLASS.events.handler(evt); }, register: function () { YAHOO.util.Event.addListener(document.body, 'click', FIRSTCLASS.events.hfunc); YAHOO.util.Event.addListener(document.body, 'dblclick', FIRSTCLASS.events.hfunc); YAHOO.util.Event.addListener(document.body, 'mouseup', FIRSTCLASS.events.hfunc); YAHOO.util.Event.addListener(document.body, 'mousedown', FIRSTCLASS.events.hfunc); YAHOO.util.Event.addListener(document.body, 'mouseover', FIRSTCLASS.events.hfunc); YAHOO.util.Event.addListener(document.body, 'mouseout', FIRSTCLASS.events.hfunc); YAHOO.util.Event.addListener(document.body, 'mousemove', FIRSTCLASS.events.hfunc); YAHOO.util.Event.addListener(document.body, 'keyup', FIRSTCLASS.events.hfunc); YAHOO.util.Event.addListener(document.body, 'focus', FIRSTCLASS.events.hfunc); YAHOO.util.Event.addListener(document.body, 'blur', FIRSTCLASS.events.hfunc); YAHOO.util.Event.addListener(window, "resize", FIRSTCLASS.events.eventHandlers.global.resizeEvent); }, registerInput: function (target) { /* set up events */ YAHOO.util.Event.addListener(target, 'focus', FIRSTCLASS.events.hfunc); YAHOO.util.Event.addListener(target, 'blur', FIRSTCLASS.events.hfunc); YAHOO.util.Event.addListener(target, 'change', FIRSTCLASS.events.hfunc); /* set up classes */ YAHOO.util.Dom.addClass(target, 'blurred'); }, unRegisterInput: function (target) { YAHOO.util.Event.removeListener(target, 'focus', FIRSTCLASS.events.hfunc); YAHOO.util.Event.removeListener(target, 'blur', FIRSTCLASS.events.hfunc); YAHOO.util.Event.removeListener(target, 'change', FIRSTCLASS.events.hfunc); } }; /** * 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.session.fcbase + "//.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.ui.fcbase.absolute + "/util/DataSource.js", requires: ['yahoo', 'dom', 'event', "connection", 'logger', "json"] }); added = FIRSTCLASS._loader.addModule({ name: "fcThread", type: "js", fullpath: FIRSTCLASS.session.ui.fcbase.absolute + "/layout/Thread.js", requires: ['fcDataSource'] }); added = FIRSTCLASS._loader.addModule({ name: "fcFormParser", type: "js", fullpath: FIRSTCLASS.session.ui.fcbase.absolute + "/util/FormParser.js", requires: ['calendar', 'carousel'] }); added = FIRSTCLASS._loader.addModule({ name: "fcChat", type: "js", fullpath: FIRSTCLASS.session.ui.fcbase.absolute + "/apps/Chat.js", requires: ['fcDataSource'] }); added = FIRSTCLASS._loader.addModule({ name: "fcListView", type: "js", fullpath: FIRSTCLASS.session.ui.fcbase.absolute + "/layout/ListView.js", requires: ['fcDataSource', 'button', 'fcThread', 'dragdrop','resize'] }); added = FIRSTCLASS._loader.addModule({ name: "fcFeed", type: "js", fullpath: FIRSTCLASS.session.ui.fcbase.absolute + "/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.ui.fcbase.absolute + "/apps/history.js", requires: ['fcListView'] }); added = FIRSTCLASS._loader.addModule({ name: "fcTableView", type: "js", fullpath: FIRSTCLASS.session.ui.fcbase.absolute + "/layout/TableView.js", requires: ['datatable'] }); added = FIRSTCLASS._loader.addModule({ name: "fcDocuments", type: "js", fullpath: FIRSTCLASS.session.ui.fcbase.absolute + "/apps/Documents.js", requires: ['fcListView', 'fcHistory','fcTableView'] }); added = FIRSTCLASS._loader.addModule({ name: "fcDiscussion", type: "js", fullpath: FIRSTCLASS.session.ui.fcbase.absolute + "/apps/Community.js", requires: ['fcListView', 'tabview'/*, 'slider'*/] }); added = FIRSTCLASS._loader.addModule({ name: "difflib", type: "js", fullpath: FIRSTCLASS.session.templatebase + "/jsdifflib/difflib.js"}); added = FIRSTCLASS._loader.addModule({ name: "diffview", type: "js", fullpath: FIRSTCLASS.session.templatebase + "/jsdifflib/diffview.js"}); added = FIRSTCLASS._loader.addModule({ name: "fcWiki", type: "js", fullpath: FIRSTCLASS.session.ui.fcbase.absolute + "/apps/Wiki.js", requires: ['fcListView', 'fcHistory','fcTableView', 'difflib','diffview'] }); added = FIRSTCLASS._loader.addModule({ name: "fcCalendar", type: "js", fullpath: FIRSTCLASS.session.ui.fcbase.absolute + "/apps/Calendar.js", requires: ['fcListView', 'datatable'] }); added = FIRSTCLASS._loader.addModule({ name: "fcTasks", type: "js", fullpath: FIRSTCLASS.session.ui.fcbase.absolute + "/apps/Tasks.js", requires: ['fcListView', 'datatable'] }); added = FIRSTCLASS._loader.addModule({ name: "fcFormDialog", type: "js", fullpath: FIRSTCLASS.session.ui.fcbase.absolute + "/apps/Account.js", requires: ['yahoo', 'dom', 'event', 'connection', /*'logger',*/ 'container','containercore','fcFormUtils','button'] }); added = FIRSTCLASS._loader.addModule({ name: "fcWorkflows", type: "js", fullpath: FIRSTCLASS.session.ui.fcbase.absolute + "/apps/Workflows.js", requires: ['fcFormDialog', 'autocomplete','progressbar'] }); added = FIRSTCLASS._loader.addModule({ name: "fcIntegration", type: "js", fullpath: FIRSTCLASS.session.ui.fcbase.absolute + "/apps/Integration.js", requires: ['fcFormDialog',"fcWorkflows", 'treeview'] }); added = FIRSTCLASS._loader.addModule({ name: "ckeditor", type: "js", fullpath: FIRSTCLASS.session.templatebase + "/cke_3.1/ckeditor.js"}); added = FIRSTCLASS._loader.addModule({ name: "fcFormUtils", type: "js", fullpath: FIRSTCLASS.session.ui.fcbase.absolute + "/util/Form.js", requires: ['yahoo', 'dom', 'event', 'connection', 'container','containercore','button', 'editor', 'autocomplete', 'ckeditor'] }); added = FIRSTCLASS._loader.addModule({ name: "fcCommunity", type: "js", fullpath: FIRSTCLASS.session.ui.fcbase.absolute + "/apps/Community.js", requires: ['fcListView', 'tabview', 'fcFeed', /*'fcMembers', */'fcFormDialog', 'fcFormUtils', /*'fcDiscussion',*/ 'fcIntegration'] }); added = FIRSTCLASS._loader.addModule({ name: "fcPulse", type: "js", fullpath: FIRSTCLASS.session.ui.fcbase.absolute + "/apps/Pulse.js", requires: ['fcListView', 'fcFeed', /*'fcMembers', */'fcFormDialog', 'fcFormUtils', /*'fcDiscussion',*/ 'fcIntegration', 'fcSearch'] }); added = FIRSTCLASS._loader.addModule({ name: "fcMessaging", type: "js", fullpath: FIRSTCLASS.session.ui.fcbase.absolute + "/apps/Messaging.js", requires: ['fcListView', 'fcFeed', /*'fcMembers', */'fcFormDialog', 'fcFormUtils', /*'fcDiscussion',*/ 'fcIntegration'] }); added = FIRSTCLASS._loader.addModule({ name: "fcWorkflowIntegration", type: "js", fullpath: FIRSTCLASS.session.ui.fcbase.absolute + "/apps/WorkflowIntegration.js", requires: ['fcListView', 'fcFeed', 'fcFormDialog', 'fcFormUtils', 'fcIntegration', 'fcFormParser'] }); added = FIRSTCLASS._loader.addModule({ name: "fcSearch", type: "js", fullpath: FIRSTCLASS.session.ui.fcbase.absolute + "/apps/Search.js", requires: ['fcListView', 'fcFeed', 'paginator', 'tabview', 'fcIntegration'] }); added = FIRSTCLASS._loader.addModule({ name: "fcMusic", type: "js", fullpath: FIRSTCLASS.session.ui.fcbase.absolute + "/apps/Music.js", requires: ['fcListView','datasource','datatable'] }); added = FIRSTCLASS._loader.addModule({ name: "fcBlog", type: "js", fullpath: FIRSTCLASS.session.ui.fcbase.absolute + "/apps/blog.js", requires: ['fcListView', 'fcFormUtils', 'fcWorkflows'] }); added = FIRSTCLASS._loader.addModule({ name: "fcBlogFeed", type: "js", fullpath: FIRSTCLASS.session.ui.fcbase.absolute + "/layout/blogfeed.js", requires: ['fcListView', 'tabview', /*'slider',*/ 'fcBlog'] }); added = FIRSTCLASS._loader.addModule({ name: "fcProfile", type: "js", fullpath: FIRSTCLASS.session.ui.fcbase.absolute + "/apps/Profile.js", requires: ['animation','imagecropper','fcFormDialog','container','containercore','button','fcBlog','fcBlogFeed','fcIntegration']}); added = FIRSTCLASS._loader.addModule({ name: "fcOrgProfile", type: "js", fullpath: FIRSTCLASS.session.ui.fcbase.absolute + "/apps/orgprofile.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", "fcSearch", "fcFormUtils"]; 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) { var loadFunc = function () { }; FIRSTCLASS._loader.onFailure = function (o) { FIRSTCLASS.session.debug.writeMessage("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) { FIRSTCLASS.session.debug.writeMessage(message, 1); /* var timeend = new Date(); var diff = timeend.getTime() - timestart.getTime(); YAHOO.log("at " + diff + " ms, message:\"" + message + "\""); */ } }; FIRSTCLASS.session.debug.writeMessage("loadApplication started", 1); 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); }; this._loader.onFailure = 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; switch (subType) { case FIRSTCLASS.subTypes.music: appName = "Music"; break; case FIRSTCLASS.subTypes.mailbox: appName = "Messaging"; break; case FIRSTCLASS.subTypes.workflowfolder: appName = "WorkflowIntegration"; break; default: appName = "Community"; } reqMods.push("fc" + appName); FIRSTCLASS._loader.require(reqMods); this._loader.onSuccess = function(o) { FIRSTCLASS.session.debug.writeMessage("loadApplication code loaded, init'ing application: \"" + appName + "\"", 1); 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(extparams); }; 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; case FIRSTCLASS.objTypes.groupProfile: FIRSTCLASS._loader.require(['fcOrgProfile', 'fcDataSource', 'fcListView','tabview']); this._loader.onSuccess = function(o) { var myProfile= new FIRSTCLASS.apps.orgProfile(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; if (params.returnurl) { return searchurl; } else { 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 = config.key; /* if (config.escapedkey) { key = config.escapedkey; }*/ var tackon = ""; if (config.tagsonly) { tackon = "&FieldID:1247%3DLONG=8021"; } if (config.doquickfilter) { tackon += "&FieldID:1238%3DLONG=0"; } else { tackon += "&FieldID:1238%3DLONG=1"; } var containers = 20; var people = 20; var usekey = key; if (YAHOO.env.ua.ie > 0) { usekey = encodeURI(key); } var searchpart = "__Search?CharSet=UTF-8&FieldID:1211%3DLONG=0&FieldID:1246%3DLONG=1&FieldID:1243%3DLONG=" + people + "&FieldID:1244%3DLONG=" + containers + "&FieldID:1234%3DLONG=0&FieldID:1229%3DLONG=0&FieldID:1239%3DLONG=1" + tackon + "&Close=-1&FieldID:1202%3DSTRING=" + usekey; if (config.scope) { baseurl = config.scope; } var searchbox = $('fcSearchInput'); if (searchbox) { searchbox.value = config.key; } if (!config.escapedkey) { config.escapedkey = escape(encodeURI(key)); } var searchurl; if (baseurl.indexOf("__Resume?FormID=97") > 0) { searchurl = FIRSTCLASS.session.baseURL + searchpart; } else { searchurl = FIRSTCLASS.lang.ensureSlashUrl(baseurl) + searchpart; } if (config.justreturnsearchurl) { return searchurl; } 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.authorSearch = function (config) { var baseurl = FIRSTCLASS.session.getActiveObject(); var key = encodeURI(config.user); /* 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:1241%3DLONG=" + config.cid + "&FieldID:1202%3DSTRING=" + key; if (config.scope) { baseurl = config.scope; } var searchurl; if(baseurl.indexOf("__Resume?FormID=97") > 0 || config.fromroot) { searchurl = FIRSTCLASS.session.baseURL + searchpart; } else { searchurl = FIRSTCLASS.lang.ensureSlashUrl(baseurl) + searchpart; } config.escapedkey = key; config.sortbylastmod = true; config.mode = 4; FIRSTCLASS.loadApplication(searchurl, FIRSTCLASS.objTypes.search, -1, config); }; 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 = $("fcDesktopIconList").parentNode;//, this._domElement); //this.activateSideBar(); this.activate(true); if (FIRSTCLASS.session.user.isvirgin) { FIRSTCLASS.apps.Help.show(); } this.desktopIconList = $('fcDesktopIconList'); FIRSTCLASS.session.UserStatuses.init(); }; FIRSTCLASS.apps.Desktop.prototype.quickFilter = function(str) { var dscfg = false; if (typeof FIRSTCLASS.session.desktop._dataSource == "undefined") { return; } if (str.length > 0) { /*var tmpstr = "", i; for (i = 0; i < str.length; i++) { tmpstr += "[" + str.charAt(i).toLowerCase() + str.charAt(i).toUpperCase() + "]"; } str = tmpstr;*/ var fields = [ "8063", "8", "7" ]; var tackon = "&FColFilter="; for (i = 0; i < fields.length; i++) { if (i !== 0) { tackon += "|"; } tackon += fields[i] + "_[.*" + encodeURI(str) + ".*]"; } dscfg = {tackon:tackon}; FIRSTCLASS.apps.Desktop.instance.pulsecallbacks.dofilter(4,str); } else { dscfg = {tackon: ""}; FIRSTCLASS.apps.Desktop.instance.pulsecallbacks.dofilter(0,str); } if (dscfg) { $('fcDesktopIconList').innerHTML = ""; FIRSTCLASS.session.desktop._dataSource.reconfigure(dscfg); } if (this._appBoxes) { if (this._appBoxes["invitations"] && this._appBoxes["invitations"].listView) { this._appBoxes["invitations"].listView.activate(); this._appBoxes["invitations"].listView.reLoadFromDataSource(); } if (this._appBoxes["flags"] && this._appBoxes["flags"].listView) { this._appBoxes["flags"].listView.activate(); this._appBoxes["flags"].listView.reLoadFromDataSource(); } if (this._appBoxes["people"] && this._appBoxes["people"].listView) { this._appBoxes["people"].listView.activate(); this._appBoxes["people"].listView.reLoadFromDataSource(); } } }; 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, 10)) { 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 = [], i; for (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); FIRSTCLASS.ui.navBar.setBottomText(""); this.activateSideBar(); if (this._dataSource) { this._dataSource.activate(); } FIRSTCLASS.ui.setDocumentTitle(FIRSTCLASS.session.user.name); FIRSTCLASS.ui.navBar.setTitle(FIRSTCLASS.session.serverName); this.resizeEvent(); if (this._appBoxes) { if (this._appBoxes["invitations"] && this._appBoxes["invitations"].listView) { this._appBoxes["invitations"].listView.activate(); this._appBoxes["invitations"].listView.reLoadFromDataSource(); } if (this._appBoxes["flags"] && this._appBoxes["flags"].listView) { this._appBoxes["flags"].listView.activate(); this._appBoxes["flags"].listView.reLoadFromDataSource(); } if (this._appBoxes["people"] && this._appBoxes["people"].listView) { this._appBoxes["people"].listView.activate(); this._appBoxes["people"].listView.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); }*/ this.activateSideBar(); if (this._pulseds) { this._pulseds.markAllAsRead(); } }; FIRSTCLASS.apps.Desktop.prototype.deactivate = function () { if (this._dataSource) { this._dataSource.deactivate(); } if (this._appBoxes) { if (this._appBoxes["invitations"] && this._appBoxes["invitations"].listView) { this._appBoxes["invitations"].listView.deactivate(); } if (this._appBoxes["people"] && this._appBoxes["people"].listView) { this._appBoxes["people"].listView.deactivate(); } if (this._appBoxes["flags"] && this._appBoxes["flags"].listView) { this._appBoxes["flags"].listView.deactivate(); } } FIRSTCLASS.ui.MiniProfile.hideBoxNow(); if (this._pulseds) { this._pulseds.markAllAsRead(); } }; 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) { 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) { 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("FAV", "FLV").replace("FOV", "FLV"); newurlpart = FIRSTCLASS.lang.removeSlashUrl(newurlpart.substr(newurlpart.indexOf("FLV1"))); newurlpart = newurlpart.substr(0,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) { if (row.wtype) { return {type: row.wtype}; } return true; } } } return false; }; FIRSTCLASS.apps.Desktop.prototype.stopContainerBeingWatched = function (baseurl) { if (this._dataSource) { var newurlpart = baseurl.replace("FAV", "FLV").replace("FOV", "FLV"); newurlpart = FIRSTCLASS.lang.removeSlashUrl(newurlpart.substr(newurlpart.indexOf("FLV"))); if (newurlpart.length > 13) { newurlpart = newurlpart.substr(0,13); } if (newurlpart.length == 13) { var rows = this._dataSource.query("uri", newurlpart, true), i; for (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 i, r, rows = this._dataSource.query("threadid", row.messageid, true); if (rows.length > 0) { for(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); } } } else { rows = this._dataSource.query("threadid", row.threadid, true); for(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); }, galleryprevious: function(that, fcevent) { var controls = fcevent.target.parentNode; YAHOO.util.Dom.setStyle(controls.firstChild, 'visibility', ''); YAHOO.util.Dom.setStyle(controls.lastChild, 'visibility', ''); var page = parseInt(controls.getAttribute('page')); var newpage = page-1; var pagediv = $('fcPicturePage' + page); var previouspage = $('fcPicturePage' + newpage); YAHOO.util.Dom.removeClass(previouspage, 'hidden'); YAHOO.util.Dom.addClass(pagediv, 'hidden'); controls.setAttribute('page', newpage); if (newpage == 1) { YAHOO.util.Dom.setStyle(fcevent.target, 'visibility', 'hidden'); } }, gallerynext: function(that, fcevent) { var controls = fcevent.target.parentNode; YAHOO.util.Dom.setStyle(controls.firstChild, 'visibility', ''); var page = parseInt(controls.getAttribute('page')); var newpage = page+1; var pages = controls.getAttribute('pages'); var pagediv = $('fcPicturePage' + page); var nextpage = $('fcPicturePage' + newpage); YAHOO.util.Dom.removeClass(nextpage, 'hidden'); YAHOO.util.Dom.addClass(pagediv, 'hidden'); controls.setAttribute('page', newpage); if (newpage == pages) { YAHOO.util.Dom.setStyle(fcevent.target, 'visibility', 'hidden'); } } } }; 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; } } if (!rv && this._appBoxes) { var i; for (i in this._appBoxes) { var box = this._appBoxes[i]; if (box.listView) { rv = box.listView.handleEvent(evt, fcevent); if (rv) { break; } } } } } 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'; FIRSTCLASS.util.net.doAsyncGet({action:joinurl}); row.col8092 = 0; this._dataSource.notifyRowDeleted(row); this._dataSource.notifyRowChanged(row); var params = { title: row.name, unread:row.status.unread, icon: row.icon.uri }; FIRSTCLASS.loadApplication(FIRSTCLASS.session.baseURL + row.uri, FIRSTCLASS.objTypes.folder, FIRSTCLASS.subTypes.community, params); } }; 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 { 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, i; for (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 uri = FIRSTCLASS.lang.removeSlashUrl(row.uri); var base = FIRSTCLASS.session.domain + FIRSTCLASS.session.baseURL; if (uri.indexOf(base) >= 0) { uri = uri.substr(base.length); } var icon = $('fcDesktopIcon'+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) { try { this.desktopIconList.replaceChild(newdiv, olddiv); } catch(e) {} } } }; FIRSTCLASS.apps.Desktop.prototype.addDesktopItem = function (row, returndiv) { var uri = FIRSTCLASS.lang.removeSlashUrl(row.uri); var base = FIRSTCLASS.session.domain + FIRSTCLASS.session.baseURL; if (uri.indexOf(base) >= 0) { uri = uri.substr(base.length); } 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 uri = FIRSTCLASS.lang.removeSlashUrl(row.uri); var base = FIRSTCLASS.session.domain + FIRSTCLASS.session.baseURL; if (uri.indexOf(base) >= 0) { uri = uri.substr(base.length); } var icon; if (div) { icon = div; } else { icon = this.getDesktopItem(row); } icon.setAttribute('fcid', 'community,ihover'); icon.setAttribute('fcattrs', uri); icon.firstChild.setAttribute('fcid', 'community'); icon.firstChild.setAttribute('fcattrs', uri); icon.firstChild.childNodes[1].setAttribute('fcid', 'community'); icon.firstChild.childNodes[1].setAttribute('fcattrs', uri); var aicon = icon.childNodes[0].childNodes[0].childNodes[0]; aicon.setAttribute('fcid', 'community'); aicon.setAttribute('fcattrs', uri); if (aicon.src != row.icon.uri) { aicon.src="/Icons/"+row.icon.id; } 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', uri); } if (row.status.protected) { YAHOO.util.Dom.addClass(icon, 'fcProtected'); } }; FIRSTCLASS.apps.Desktop.prototype.caclProfileCompleteness = function (profileData) { var profileDataCompleteness = []; 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) { if (true) { return; // no longer have bargraph on home page } 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.updateTags = function (tags) { this.personaltags = FIRSTCLASS.ui.parseServerTags(tags); if (this._appBoxes && this._appBoxes["tags"]) { this._appBoxes["tags"].domElement.innerHTML = FIRSTCLASS.ui.generateCloud(this.personaltags); } }; 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); } } }; FIRSTCLASS.util.net.doAsyncHead({action:FIRSTCLASS.util.User.getLargeProfPicUrlByCid(FIRSTCLASS.session.user.cid,false),callbacks: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, i; for (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.totalusers + ", " + stats.fcpSysUsersOnline + " " + FIRSTCLASS.locale.desktop.summ.online + "
"; var subheader = document.createElement("div"); subheader.innerHTML = peoplestr; FIRSTCLASS.ui.leftSideBar.updateBoxSubHeader(FIRSTCLASS.locale.pulse.lbl, subheader); this._stats = stats; }; FIRSTCLASS.apps.Desktop.prototype.init = function () { var that = this; var dsconfig = { containerBaseUrl:FIRSTCLASS.session.baseURL, itemrequest: false, loadFull: true, watchForTinkle: true, closeParam: "&Close=-1", nosymbiomainfetch: true, paramStr: "&Watches=1&Communities=1&Pulse=1", pollInterval: 1000, 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, name: "Desktop" }; 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.updateTags(contents); break; case "session": that.updateStatsCounters(contents.stats); break; default: break; } }, filter: function (key) { switch (key) { case "profile": case "tags": case "session": return true; default: return false; } } }); this._peoplelistds = new FIRSTCLASS.util.DataSource( { globalDataListener: {key:"mypeople"}, itemrequest: false, compareRows: function (row1, row2) { return row1.online == row2.online; }, isSameRow: function (row1, row2) { return row1.uid == row2.uid; }, name: "Desktop People" }); this._pulseds = new FIRSTCLASS.util.DataSource( { containerBaseUrl:FIRSTCLASS.session.baseURL+"__Open-Item/ThePulse", globalDataListener: {key:"thepulse"}, isDualDataSource: true, autoLoad: false, watchForNew: false, messagebodies: false, nosymbiomainfetch: true, sortFirstFetch: false, serversort: "&Table=-3_9", paramStr: "&NoBodies=1", fetchThreads: true, initialRequestGranularity: 20, requestGranularity: 20, expandcfg: { urls: true, maxurl: 23, maxstr: 23 }, name: "Pulse" }); 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 (row.col8092 && row.col8092 == 3 && this.fillCount > 1) { if (FIRSTCLASS.appProperties.sounds.supported && FIRSTCLASS.appProperties.sounds.desktop.watches) { soundManager.play("watch1"); } that.animateDiv(that._appBoxes["invitations"].listView._generateDivID(row)); } if (row.typedef.subtype == FIRSTCLASS.subTypes.profile && !row.status.alias) { /*FIRSTCLASS.ui.navBar.setProfileUnread(row.status.unread, row.uri);*/ /* FIXME: update pulsheader unread count instead*/ var profpicunread = $('myprofileunread'); if (row.status.unread) { YAHOO.util.Dom.addClass(profpicunread, 'visible'); } else { YAHOO.util.Dom.removeClass(profpicunread, 'visible'); } } 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 (row.status && row.col8092 && row.col8092 == 2 && row.status.unread && !oldrow.status.unread && this.fillCount > 1) { if (FIRSTCLASS.appProperties.sounds.supported && FIRSTCLASS.appProperties.sounds.desktop.watches) { soundManager.play("watch1"); } that.animateDiv(that._appBoxes["flags"].listView._generateDivID(row)); } else if (typeof row.online != "undefined") { if (row.online && (oldrow && !oldrow.online || !oldrow)) { if (FIRSTCLASS.appProperties.sounds.supported && FIRSTCLASS.appProperties.sounds.desktop.contacts.on) { soundManager.play("contact1"); } if (that._appBoxes["people"]) { that.animateDiv(that._appBoxes["people"].listView._generateDivID(row)); } } else if (!row.online && (oldrow && !oldrow.online || !oldrow)){ if (FIRSTCLASS.appProperties.sounds.supported && FIRSTCLASS.appProperties.sounds.desktop.contacts.off) { soundManager.play("contact2"); } if (that._appBoxes["people"]) { that.animateDiv(that._appBoxes["people"].listView._generateDivID(row)); } } } if (row.status && oldrow && row.status.unread && !oldrow.status.unread) { if (FIRSTCLASS.appProperties.sounds.supported && FIRSTCLASS.appProperties.sounds.desktop.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 (oldrow && row.online && !oldrow.online && row.uid != FIRSTCLASS.session.user.cid) { FIRSTCLASS.extensions.notify(row.name + " has signed on", row.message, FIRSTCLASS.session.ui.fcbase.absolute + "/images/online.png"); } else if (oldrow && row.message != oldrow.message && row.uid != FIRSTCLASS.session.user.cid) { FIRSTCLASS.extensions.notify(row.name + " has changed their status", row.message, FIRSTCLASS.session.ui.fcbase.absolute + "/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);*/ /* FIXME: update pulsheader unread count instead*/ var profpicunread = $('myprofileunread'); if (row.status.unread) { YAHOO.util.Dom.addClass(profpicunread, 'visible'); } else { YAHOO.util.Dom.removeClass(profpicunread, 'visible'); } } } 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; } if (FIRSTCLASS.apps.Global) { FIRSTCLASS.apps.Global.chat.listener.fillFinished(); } } }; FIRSTCLASS.util.BuddyList.setDataSource(that._peoplelistds); that._dataSource.addRowListener(that.rowHandler); that._peoplelistds.addRowListener(that.rowHandler); that.pulseHandler = { onHeaderData: function (key, contents) { //debugger; if (key == "session") { FIRSTCLASS.session.updates.pulse = contents.updates.pulse; } }, filter: function (key) { switch (key) { case "session": return true; default: return false; } } }; that._pulseds.addDataListener(that.pulseHandler); that.activateSideBar = function () { var i, date = new Date(), layout = { sidebars: { left: { visible: true, width: '20%', contents: [ /*{id:"people"}*/ ] }, right: { visible: true, contents: [ {id:"tags"}, {id:"profile"}, {id:"invitations"}, {id:"flags"} ] } } }; if (FIRSTCLASS.session.user.haspulse) { layout.sidebars.left.contents = [ {id: "pulseheader"}, {id: "pulse"} ]; } else { layout.sidebars.left.visible = false; layout.sidebars.right.contents = [{id: "pulseheader"}].concat(layout.sidebars.right.contents); } if (FIRSTCLASS.skin && FIRSTCLASS.skin.desktop && FIRSTCLASS.skin.desktop.sidebars) { layout = FIRSTCLASS.skin.desktop; } FIRSTCLASS.ui.leftSideBar.resetApplicationBoxContents(); if (layout.sidebars.left.visible) { FIRSTCLASS.ui.leftSideBar.show(false, false, layout.sidebars.left.width); for (i in layout.sidebars.left.contents) { that.buildApplicationBox(FIRSTCLASS.ui.leftSideBar, layout.sidebars.left.contents[i]); } } else { FIRSTCLASS.ui.leftSideBar.hide(); } FIRSTCLASS.ui.rightSideBar.resetApplicationBoxContents(); if (layout.sidebars.right.visible) { FIRSTCLASS.ui.rightSideBar.show(false, false, layout.sidebars.right.width); for (i in layout.sidebars.right.contents) { that.buildApplicationBox(FIRSTCLASS.ui.rightSideBar, layout.sidebars.right.contents[i]); } } else { FIRSTCLASS.ui.rightSideBar.hide(); } FIRSTCLASS.ui.navBar.setProfilePicture(FIRSTCLASS.session.serverIcon); FIRSTCLASS.ui.navBar.setTitle(FIRSTCLASS.session.serverName); //FIRSTCLASS.ui.navBar.setProfileStatus(that._config.profileStatus, that); }; }; FIRSTCLASS.apps.Desktop.prototype.getApplicationBox = function (boxid) { if (!this._appBoxes) { this._appBoxes = {}; } else if (this._appBoxes[boxid]) { return this._appBoxes[boxid]; } var that = this; var div = document.createElement("div"); var cfg = {}; cfg.domElement = div; switch (boxid) { case "profile": div.innerHTML = "Click here to create your profile"; YAHOO.util.Dom.setStyle(div,"cursor","pointer"); YAHOO.util.Event.addListener(div, '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(div, 'fcProfileUpdateInfo'); break; case "people": var buddylistcfg = { domElement: div, dataSource: this._peoplelistds, keepRowsSorted: true, threading: { format: FIRSTCLASS.layout.ThreadHandler.types.NONE, sortfunc: function (row1, row2) { var weight1 = "9999"; if (row1.online > 0) { weight1 = "1111"; } if (false && row1.status.unread) { weight1 = "0000"; } var weight2 = "9999"; if (row2.online > 0) { weight2 = "1111"; } if (false && 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; } }, expandcfg: { urls: true, maxurl: 23, maxstr: 23 } }, rowFilter: function (row) { return (row.typedef.subtype == FIRSTCLASS.subTypes.profile && row.status.alias && row.status.deleted === 0); }, onFillFinished: function () { if (false && 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(this._dataSource, false, false, false, false, true) }; cfg.listView = new FIRSTCLASS.layout.ListView(buddylistcfg); break; case "invitations": var notificationlistcfg = { domElement: div, dataSource: this._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(this._dataSource) }; cfg.listView = new FIRSTCLASS.layout.ListView(notificationlistcfg); break; case "flags": var watchlistcfg = { domElement: div, dataSource: this._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(this._dataSource) }; cfg.listView = new FIRSTCLASS.layout.ListView(watchlistcfg); break; case "tags": var tags = [{tag:FIRSTCLASS.locale.desktop.tag.info, weight:1, clickable:false}]; div.innerHTML = FIRSTCLASS.ui.generateCloud(tags); break; case "pulseheader": var prompt = FIRSTCLASS.locale.pulse.prompt; div.innerHTML = "
"+ FIRSTCLASS.session.user.name + "
"; var input = FIRSTCLASS.ui.Dom.getChildByIdName('pulseinput', div); var parent = input.parentNode; var contentPane = FIRSTCLASS.ui.widgets.buildTightContentBox(input, 'fcWhiteContentBox'); parent.appendChild(contentPane); FIRSTCLASS.events.registerInput(input); YAHOO.util.Dom.addClass(div, 'pulseheader'); FIRSTCLASS.locale.setElementRole("form", cfg.domElement); break; case "pulse": var pulselistcfg = { domElement: div, dataSource: this._pulseds, keepRowsSorted: true, feedConfig: { inlineReplyFormID: 21002, inlineReplySubFormID: 0, coercion: { allowed: {"21008": {lformid:21008}}, coerce: {lformid:21008} }, bodyType: "plain" }, threading: { format: "bythread", originRowIsHeader: true, collapseRead: true, displayThreadContributors: false, summaryMode: "summary", sortfunc: function (row1, row2) { var result = true; if (!row1.status.backversion && (row1.typedef.objtype == FIRSTCLASS.objTypes.fcfile || row1.typedef.objtype == FIRSTCLASS.objTypes.file || row1.typedef.objtype == FIRSTCLASS.objTypes.odocument)) { return -1; } else if (!row2.status.backversion && (row2.typedef.objtype == FIRSTCLASS.objTypes.fcfile || row2.typedef.objtype == FIRSTCLASS.objTypes.file || row2.typedef.objtype == FIRSTCLASS.objTypes.odocument)) { return 1; } if (row1.col8090 && row2.col8090 && (row1.typedef.objtype == FIRSTCLASS.objTypes.fcfile || row1.typedef.objtype == FIRSTCLASS.objTypes.file || row1.typedef.objtype == FIRSTCLASS.objTypes.odocument) && (row2.typedef.objtype == FIRSTCLASS.objTypes.fcfile || row2.typedef.objtype == FIRSTCLASS.objTypes.file || row2.typedef.objtype == FIRSTCLASS.objTypes.odocument)) { if (row1.col8090 < row2.col8090) { return -1; } else if (row1.col8090 == row2.col8090) { return 0; } else { return 1; } } if (row1.parsedDate < row2.parsedDate) { return -1; } else if (row1.parsedDate == row2.parsedDate) { return 0; } else { return 1; } return result; }, threadsortfunc: function (row1, row2) { if (row1 && row2) { if (row1.parsedDate < row2.parsedDate) { return 1; } else if (row1.parsedDate == row2.parsedDate) { return 0; } else { return -1; } } return 1; } }, padText:"" + FIRSTCLASS.locale.pulse.more + "" /*, rowHandler: new FIRSTCLASS.layout.Feed(this._dataSource)*/ }; cfg.listView = new FIRSTCLASS.layout.ListView(pulselistcfg); YAHOO.util.Dom.addClass(div, 'pulse'); // FIRSTCLASS.locale.setElementRole("complementary", cfg.domElement); break; default: } this._appBoxes[boxid] = cfg; return cfg; }; FIRSTCLASS.apps.Desktop.prototype.pulsecallbacks = { _currentFilter: {type:-1, param: false}, dofilter: function (type, param) { if (this._currentFilter.type == type && this._currentFilter.param == param) { return; } var ds = FIRSTCLASS.apps.Desktop.instance._pulseds; var dscfg = false; switch (type) { case 0: // everyone this.clearfilter(); return; case 1: // my people dscfg = {tackon:"&AuthorGFilter=MyPeople;Me", containerBaseUrl: FIRSTCLASS.session.baseURL + "__Open-Item/ThePulse/", filter: "MyPeople"}; break; case 2: // me dscfg = {tackon:"&AuthorGFilter=Me", containerBaseUrl: FIRSTCLASS.session.baseURL + "__Open-Item/ThePulse/", filter: "Me"}; break; case 4: // quickfilter var fields = [ "8063", "8", "7" ]; var tackon = "&ColGFilter="; for (i = 0; i < fields.length; i++) { if (i !== 0) { tackon += "|"; } tackon += fields[i] + "_[.*" + param + ".*]"; } dscfg = {tackon:tackon, containerBaseUrl: FIRSTCLASS.session.baseURL + "The%20Pulse/", filter: false}; break; default: } if (dscfg) { ds.reconfigure(dscfg); this._currentFilter = {type:type, param: param}; FIRSTCLASS.apps.Desktop.instance._appBoxes["pulse"].listView.reLoadFromDataSource(); } }, clearfilter: function () { this._currentFilter = -1; FIRSTCLASS.apps.Desktop.instance._pulseds.reset(); FIRSTCLASS.apps.Desktop.instance._appBoxes["pulse"].listView.reLoadFromDataSource(); } }; FIRSTCLASS.apps.Desktop.prototype.buildApplicationBox = function (sidebar, boxinfo) { if (boxinfo.type === "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 = "