/** * Class Description * @namespace FIRSTCLASS.layout * @module Feed * @requires * @optional * @title Feed Application */ /** * Constructor definition * @class Feed * @constructor * @param {} * @param ... */ FIRSTCLASS.layout.Feed = function(config) { var that = this, i, cfg; this._config = config; this.instance = FIRSTCLASS.layout.Feed.instances++; if (!FIRSTCLASS.layout.Feed._rowTemplateDomElement) { FIRSTCLASS.layout.Feed._rowTemplateDomElement = document.createElement("div"); var template = []; template.push(""); template.push(""); template.push(""); template.push(""); template.push(""); template.push(""); template.push("
"); template.push("
"); template.push(""); template.push("
"); template.push("
 
"); template.push("
"); template.push("
,
"); template.push("
"); template.push("
"); FIRSTCLASS.layout.Feed._rowTemplateDomElement.innerHTML = template.join(""); } if (config.listView) { this.listView = config.listView; } this._dataSource = config.dataSource; this.toolBarDomElement = document.createElement("div"); this.elementWithToolbar = false; this.findRowElement = function(evt){ var tg = YAHOO.util.Event.getTarget(evt); var row = that.listView._rowmap[tg.id]; if (YAHOO.util.Dom.isAncestor(that._selectedElement, tg)) { tg = that._selectedElement; row = that._selectedRow; } else { var otg = tg; while (tg && !row && tg !== that.listView.contentsDomElement && tg.parentNode) { tg = tg.parentNode; row = that.listView._rowmap[tg.id]; } if (!row && !tg.parentNode) { tg = otg; row = tg.row; while (tg && !row && tg !== that.listView.contentsDomElement && tg.parentNode) { tg = tg.parentNode; row = tg.row; } } } if (row) { return {"el":tg, "row":row}; } else { return that.listView.findRowElement(evt); } }; this.toolBarButtonCfg = { domElement:this.toolBarDomElement, buttons: [] }; if (this._config.toolbarcfg) { var customizer = function(el) { if (that._selectedRow) { el.setAttribute('fcattrs', that._selectedRow.messageid); } }; for (i in this._config.toolbarcfg.buttons) { cfg = this._config.toolbarcfg.buttons[i]; cfg.customizer = customizer; this.toolBarButtonCfg.buttons.push(cfg); } } if (!this._config.toolbarcfg || this._config.toolbarcfg.includeStandardButtons) { var defaultbuttons = [ { id: "fcFeedAcceptMember" + this.instance, label: FIRSTCLASS.locale.workflows.acceptmember.accept, fcid: 'acceptmember', condition: function(row) { var hasbutton = FIRSTCLASS.layout.Feed.helpers.hasToolBarButton(row, 'acceptmember', that._config); if (!hasbutton) { return false; } return (row.icon.id == 24094 && FIRSTCLASS.permissions.hasPriv(row.acl, FIRSTCLASS.permissions.ACL.EDITACL)); }, customizer: function(el) { if (that._selectedRow && that._selectedRow.memberAccepted) { el.innerHTML = FIRSTCLASS.locale.workflows.acceptmember.accepted; } else { el.innerHTML = FIRSTCLASS.locale.workflows.acceptmember.accept; } if (that._selectedRow) { el.setAttribute('fcattrs', that._selectedRow.creatorcid); } } }, { id: "fcFeedApprove" + this.instance, label: "approve", fcid: 'approve', condition: function(row) { return row.status.unapproved && FIRSTCLASS.permissions.hasPriv(row.acl, FIRSTCLASS.permissions.ACL.APPROVE); }/*, customizer: function(el) { if (that._selectedRow && that._selectedRow.memberAccepted) { el.innerHTML = FIRSTCLASS.locale.workflows.acceptmember.accepted; } else { el.innerHTML = FIRSTCLASS.locale.workflows.acceptmember.accept; } if (that._selectedRow) { el.setAttribute('fcattrs', that._selectedRow.creatorcid); } }*/ }, { id: "fcFeedReply" + this.instance, label: FIRSTCLASS.locale.toolbars.feed.reply, fcid: "reply", condition: function(row) { var hasbutton = FIRSTCLASS.layout.Feed.helpers.hasToolBarButton(row, 'reply', that._config); if (!hasbutton) { return false; } return (FIRSTCLASS.permissions.hasPriv(row.acl, FIRSTCLASS.permissions.ACL.SEND) && (row.typedef.objtype == FIRSTCLASS.objTypes.message || row.typedef.objtype == FIRSTCLASS.objTypes.confitem) && (!FIRSTCLASS.lexi.isQuestion(row.subject) || row.lformid == 21008)) && row.threadid != "0"; } }, { id: "fcFeedLike" + this.instance, label: 'like', fcid: "like", condition: function(row) { var hasbutton = FIRSTCLASS.layout.Feed.helpers.hasToolBarButton(row, this.fcid, that._config); if (!hasbutton) { return false; } return hasbutton; } }, { id: "fcFeedAnswer" + this.instance, label: FIRSTCLASS.locale.toolbars.feed.answer, fcid: 'answer', condition: function(row) { var hasbutton = FIRSTCLASS.layout.Feed.helpers.hasToolBarButton(row, 'answer', that._config); if (!hasbutton) { return false; } return (row.icon.id != 24094 && FIRSTCLASS.permissions.hasPriv(row.acl, FIRSTCLASS.permissions.ACL.SEND) && (row.typedef.objtype == FIRSTCLASS.objTypes.message || row.typedef.objtype == FIRSTCLASS.objTypes.confitem) && FIRSTCLASS.lexi.isQuestion(row.subject)) && row.threadid != "0" && row.lformid != 21008; } }, { id: "fcFeedQuote" + this.instance, label: FIRSTCLASS.locale.toolbars.feed.quote, fcid: 'quote', condition: function(row) { var hasbutton = FIRSTCLASS.layout.Feed.helpers.hasToolBarButton(row, 'quote', that._config); if (!hasbutton) { return false; } var sel = FIRSTCLASS.ui.getSelection(); return (FIRSTCLASS.permissions.hasPriv(row.acl, FIRSTCLASS.permissions.ACL.SEND) && (row.typedef.objtype == FIRSTCLASS.objTypes.message || row.typedef.objtype == FIRSTCLASS.objTypes.confitem) && (sel.length > 0)) && row.threadid != "0"; } }, { id: "fcFeedComment" + this.instance, label: FIRSTCLASS.locale.toolbars.feed.comment, fcid: 'comment', condition: function(row) { var hasbutton = FIRSTCLASS.layout.Feed.helpers.hasToolBarButton(row, 'comment', that._config); if (!hasbutton) { return false; } return (row.icon.id == 24094 && FIRSTCLASS.permissions.hasPriv(row.acl, FIRSTCLASS.permissions.ACL.SEND)) || FIRSTCLASS.permissions.hasPriv(row.acl, FIRSTCLASS.permissions.ACL.SEND) && (row.typedef.objtype == FIRSTCLASS.objTypes.odocument || row.typedef.objtype == FIRSTCLASS.objTypes.file || row.lformid == 21008) && row.threadid != "0"; } }, { id: 'fcFeedShowForm', fcid:'showform', label: 'show form', condition: function(row) { var hasbutton = FIRSTCLASS.layout.Feed.helpers.hasToolBarButton(row, 'showform', that._config); if (!hasbutton) { return false; } return true; } }, { id: "fcFeedEdit" + this.instance, label: FIRSTCLASS.locale.toolbars.feed.edit, fcid: 'editdoc', condition: function(row) { var hasbutton = FIRSTCLASS.layout.Feed.helpers.hasToolBarButton(row, 'edit', that._config); if (!hasbutton) { return false; } var enable = false; if (row.typedef.objtype == FIRSTCLASS.objTypes.file && row.threadid != "0") { if (FIRSTCLASS.permissions.hasPriv(row.acl, FIRSTCLASS.permissions.ACL.DELETE)) { if ((FIRSTCLASS.ui.webdav.osPlatform() == "windows") && FIRSTCLASS.util.Display.isEditableOfficeFile(row.name)) { if (YAHOO.env.ua.ie || YAHOO.env.ua.gecko) { enable = true; } } } } return enable; } }, { id: "fcFeedShare" + this.instance, label: FIRSTCLASS.locale.toolbars.wiki.share, fcid: 'share', type: "popup", popup: { width: 320, height: 500, callbacks: { onRender: function(evt, el) { FIRSTCLASS.ui.sharePopup.showShareDialog(evt.currentTarget,el,that._selectedRow,that._dataSource,"email"); }, onClose: function() { } } }, condition: function(row) { if (FIRSTCLASS.layout.Feed.helpers.hasToolBarButton(row, 'share', that._config)) { return row.threadid != "0"; } else { return false; } } }, { id: "fcFeedSendTo" + this.instance, label: FIRSTCLASS.locale.toolbars.feed.sendto, fcid: 'sendto', condition: function(row) { var hasbutton = FIRSTCLASS.layout.Feed.helpers.hasToolBarButton(row, 'sendto', that._config); if (hasbutton && FIRSTCLASS.apps.Integration && FIRSTCLASS.apps.Integration.getRepositories() && FIRSTCLASS.apps.Integration.getRepositories().length > 0) { return hasbutton; } else { return false; } // the rest is old cruft if (!hasbutton) { return false; } /** FIXME: MAKING UP FOR JEFF's INADEQUACIES in CS1 demo, this is CRAP **/ var trow = {}; if (!row.linkinfo) { var rows = that._dataSource.query("threadid", row.threadid, false, false); for (var i = 0; i < rows.length; i++) { if (rows[i][1].linkinfo) { trow = rows[i][1]; break; } } } if (trow.linkinfo && !row.linkinfo) { row.linkinfo = trow.linkinfo; } /** FIXME: MAKING UP FOR JEFF's INADEQUACIES in CS1 demo, this is CRAP **/ if (FIRSTCLASS.apps.Integration && FIRSTCLASS.apps.Integration.getRepositories() && FIRSTCLASS.apps.Integration.getRepositories().length > 0 && row.linkinfo) { return row.threadid != "0"; } else { return false; } } }, { id: "fcFeedDelete"+ this.instance, label: FIRSTCLASS.locale.toolbars.feed.del, fcid: 'fcdelete', condition: function(row) { var hasbutton = FIRSTCLASS.layout.Feed.helpers.hasToolBarButton(row, 'fcdelete', that._config); if (!hasbutton) { return false; } if (row.threadid == "0") { return false; } var delown = FIRSTCLASS.permissions.hasPriv(row.acl, FIRSTCLASS.permissions.ACL.DELETEOWN); var del = FIRSTCLASS.permissions.hasPriv(row.acl, FIRSTCLASS.permissions.ACL.DELETE); if (del) { return true; } else if (delown && FIRSTCLASS.session.user.cid == row.creatorcid) { return true; } return false; } }, { id: "fcFeedWatch" + this.instance, label: FIRSTCLASS.locale.toolbars.feed.watch, type: "unchecked", fcid: 'feedwatch', condition: function(row) { var hasbutton = FIRSTCLASS.layout.Feed.helpers.hasToolBarButton(row, 'flag', that._config); if (!hasbutton) { return false; } if (row.threadid == "0") { return false; } var rv = true; if (FIRSTCLASS.session.desktop && FIRSTCLASS.session.desktop._dataSource) { rv = !FIRSTCLASS.session.desktop.isThreadBeingWatched(row.threadid); } if (row.watched && rv) { rv = false; } return rv; }}, { id: "fcFeedUnWatch" + this.instance, label: FIRSTCLASS.locale.toolbars.feed.watch, type: "checked", fcid: 'feedunwatch', condition: function(row) { var hasbutton = FIRSTCLASS.layout.Feed.helpers.hasToolBarButton(row, 'flag', that._config); if (!hasbutton) { return false; } if (row.threadid == "0") { return false; } var rv = false; if (FIRSTCLASS.session.desktop && FIRSTCLASS.session.desktop._dataSource) { rv = FIRSTCLASS.session.desktop.isThreadBeingWatched(row.threadid); } if (row.watched && !rv) { rv = true; } return rv; }}, { id: "fcFeedTag" + this.instance, label: FIRSTCLASS.locale.toolbars.feed.tag, fcid: 'dotag', condition: function (row) { var hasbutton = FIRSTCLASS.layout.Feed.helpers.hasToolBarButton(row, 'dotag', that._config); if (!hasbutton) { return false; } return row.threadid != "0"; } }, { id: "fcFeedPrint" + this.instance, label: FIRSTCLASS.locale.toolbars.feed.print, fcid: 'print', condition: function (row) { var hasbutton = FIRSTCLASS.layout.Feed.helpers.hasToolBarButton(row, 'print', that._config); if (!hasbutton) { return false; } return true; } }, { id: "fcFeedPermaLink" + this.instance, label: FIRSTCLASS.locale.toolbars.feed.permalink, fcid: 'permalink', condition: function(row) { var hasbutton = FIRSTCLASS.layout.Feed.helpers.hasToolBarButton(row, 'permalink', that._config); if (!hasbutton) { return false; } return true; }, customizer: function(el) { if (that._selectedRow) { var l = FIRSTCLASS.locale.toolbars.feed.permalink; var ls = l.split("|"); if (ls.length == 1) { ls[1] = ""; } FIRSTCLASS.ui.Dom.setInnerHTML(el, ""+ls[0]+""); } } }, { id: "fcFeedDeselect"+ this.instance, label: "|" + FIRSTCLASS.locale.toolbars.feed.dismiss, fcid: 'fcdeselect', condition: function(row) { var hasbutton = FIRSTCLASS.layout.Feed.helpers.hasToolBarButton(row, 'fcdeselect', that._config); return hasbutton; } } ]; for (i in defaultbuttons) { this.toolBarButtonCfg.buttons.push(defaultbuttons[i]); } } this.toolBar = new FIRSTCLASS.ui.toolBar(this.toolBarButtonCfg); FIRSTCLASS.layout.Feed.initializeTemplates(); }; FIRSTCLASS.layout.Feed.initializeTemplates = function() { if (FIRSTCLASS.layout.Feed.templates.initialized) { return; } FIRSTCLASS.layout.Feed.templates.defaultTemplateElement = document.createElement("div"); var template; template = []; template.push(""); template.push(""); template.push(""); template.push(""); template.push(""); template.push(""); template.push("
"); template.push("
"); template.push(""); template.push("
"); template.push("
 
"); template.push("
"); template.push("
,
"); template.push("
"); template.push("
"); FIRSTCLASS.layout.Feed.templates.defaultTemplateElement.innerHTML = template.join(""); var element; var tbactions = {}; for (var i in FIRSTCLASS.layout.Feed.templates.fallback.toolbar) { tbactions[FIRSTCLASS.layout.Feed.templates.fallback.toolbar[i]] = true; } FIRSTCLASS.layout.Feed.templates.fallback.toolbar = tbactions; var initializeTemplateSet = function(set) { for (var j in set) { var obj = set[j]; if (obj.experimental && FIRSTCLASS.session.ui.experimental || !obj.experimental) { if (obj.html) { element = document.createElement("div"); element.innerHTML = obj.html; } else { element = FIRSTCLASS.layout.Feed.templates.defaultTemplateElement; } if (obj.toolbar) { var tbactions = {}; for (var i in obj.toolbar) { tbactions[obj.toolbar[i]] = true; } obj.toolbar = tbactions; } } else { element = FIRSTCLASS.layout.Feed.templates.defaultTemplateElement; } obj.clone = element; if (!obj.renderer || obj.experimental && !FIRSTCLASS.session.ui.experimental) { obj.renderer = FIRSTCLASS.layout.Feed.updateRowFallBack; obj.descriptors = FIRSTCLASS.layout.Feed.templates.fallback.descriptors; } if (!obj.toolbar || obj.experimental && !FIRSTCLASS.session.ui.experimental) { obj.toolbar = FIRSTCLASS.layout.Feed.templates.fallback.toolbar; } } }; var templateskin = (FIRSTCLASS.skin && FIRSTCLASS.skin.feed && FIRSTCLASS.skin.feed.templates); if (templateskin && FIRSTCLASS.skin.feed.templates.byformid) { initializeTemplateSet(FIRSTCLASS.skin.feed.templates.byformid); } if (templateskin && FIRSTCLASS.skin.feed.templates.bysubtype) { initializeTemplateSet(FIRSTCLASS.skin.feed.templates.bysubtype); } if (templateskin && FIRSTCLASS.skin.feed.templates.byobjtype) { initializeTemplateSet(FIRSTCLASS.skin.feed.templates.byobjtype); } initializeTemplateSet(FIRSTCLASS.layout.Feed.templates.byformid); initializeTemplateSet(FIRSTCLASS.layout.Feed.templates.bysubtype); initializeTemplateSet(FIRSTCLASS.layout.Feed.templates.byobjtype); /* for (var j in FIRSTCLASS.layout.Feed.templates.bysubtype) { var obj = FIRSTCLASS.layout.Feed.templates.bysubtype[j]; if (obj.experimental && FIRSTCLASS.session.ui.experimental || !obj.expermental) { if (obj.html) { element = document.createElement("div"); element.innerHTML = obj.html; } else { element = FIRSTCLASS.layout.Feed.templates.defaultTemplateElement; } if (obj.toolbar) { var tbactions = {}; for (var i in obj.toolbar) { tbactions[obj.toolbar[i]] = true; } obj.toolbar = tbactions; } } else { element = FIRSTCLASS.layout.Feed.templates.defaultTemplateElement; } obj.clone = element; if (!obj.renderer) { obj.renderer = FIRSTCLASS.layout.Feed.updateRowFallBack; obj.descriptors = FIRSTCLASS.layout.Feed.templates.fallback.descriptors; } if (!obj.toolbar) { obj.toolbar = FIRSTCLASS.layout.Feed.templates.fallback.toolbar; } } for (var j in FIRSTCLASS.layout.Feed.templates.byobjtype) { var obj = FIRSTCLASS.layout.Feed.templates.byobjtype[j]; if (obj.experimental && FIRSTCLASS.session.ui.experimental || !obj.expermental) { if (obj.html) { element = document.createElement("div"); element.innerHTML = obj.html; } else { element = FIRSTCLASS.layout.Feed.templates.defaultTemplateElement; } if (obj.toolbar) { var tbactions = {}; for (var i in obj.toolbar) { tbactions[obj.toolbar[i]] = true; } obj.toolbar = tbactions; } } else { element = FIRSTCLASS.layout.Feed.templates.defaultTemplateElement; } obj.clone = element; if (!obj.renderer) { obj.renderer = FIRSTCLASS.layout.Feed.updateRowFallBack; obj.descriptors = FIRSTCLASS.layout.Feed.templates.fallback.descriptors; } if (!obj.toolbar) { obj.toolbar = FIRSTCLASS.layout.Feed.templates.fallback.toolbar; } }*/ FIRSTCLASS.layout.Feed.templates.initialized = true; }; FIRSTCLASS.layout.Feed.helpers = { getTemplateObj: function(row, feedconfig) { var obj = false; var templateskin = (FIRSTCLASS.skin && FIRSTCLASS.skin.feed && FIRSTCLASS.skin.feed.templates); if (templateskin) { obj = this.getSkinTemplateObj(row, FIRSTCLASS.skin.feed.templates, feedconfig); } if (!obj) { obj = this.getTemplateObjFromTemplate(row, FIRSTCLASS.layout.Feed.templates, feedconfig); } return obj; }, getTemplateObjFromTemplate: function(row, templates, feedconfig) { var obj = false; var lformid = row.lformid; if (!lformid && row.replyobjtype) { lformid = 21003; } if (feedconfig && feedconfig.coercion) { var allowed = false; if (typeof lformid != "undefined") { allowed = feedconfig.coercion.allowed[lformid]; } if (typeof allowed == "undefined" || !allowed || typeof allowed == "object" && allowed.lformid != lformid) { lformid = feedconfig.coercion.coerce.lformid; } } if (lformid && lformid !== 0) { obj = templates.byformid[lformid]; } if (!obj && row.typedef.subtype && templates.bysubtype[row.typedef.subtype]) { obj = templates.bysubtype[row.typedef.subtype]; } if (!obj && row.typedef.objtype && templates.byobjtype[row.typedef.objtype]) { obj = templates.byobjtype[row.typedef.objtype]; if (obj && obj.useformid) { obj = templates.byformid[obj.useformid]; } } return obj; }, hasToolBarButton: function(row, id, feedconfig) { var obj = FIRSTCLASS.layout.Feed.helpers.getTemplateObj(row, feedconfig); var rc = false; if (obj) { if (obj.toolbar && obj.toolbar[id]) { rc = true; } } return rc; }, doCommonRenderActions: function(cfg) { if (cfg.row.status.unread) { YAHOO.util.Dom.addClass(cfg.element, "unread"); } else { YAHOO.util.Dom.removeClass(cfg.element, "unread"); if (cfg.oldrow && cfg.oldrow.status.unread) { YAHOO.util.Dom.addClass(cfg.element, "recentlyread"); } } }, getNameHTML: function(row, suffix) { var nm = row.name; if (row.col8082) { nm = row.col8082; } if (row.status.outgoing) { nm = FIRSTCLASS.session.user.name; } var html = []; if (row.creatorcid && !row.status.replicated) { html.push("
"); } else if (row.creatorcid) { html.push("
 "); } else { html.push(""); return html.join(""); }, getCommunityLinkHTML: function(cname, ccid) { var uri = "__Open-Conf/CID" + ccid; var nameHtml = "" + cname +""; return nameHtml; }, getVersionHTML: function(row) { var name = FIRSTCLASS.lang.mlesc(row.name); if (row.linkinfo) { var verstr = ""; if (row.col8090) { verstr = " (" + FIRSTCLASS.locale.history.version.doSub({version:row.col8090}) + ")"; } return FIRSTCLASS.locale.integrations.feedimported.doSub({name:name, repository: "" + row.linkinfo.repository + ""}) + verstr; } else if (row.col8090 && row.col8090 > 1) { return FIRSTCLASS.locale.community.feed.updated.doSub({name:name, version: row.col8090}); } else { return FIRSTCLASS.locale.community.feed.uploaded.doSub({name: name}); } }, getTinyProfilePictureUrl: function(row) { var picurl; var cid; if (row.itemdata && row.itemdata.from) { picurl = FIRSTCLASS.util.User.getSmallProfPicUrlByCid(row.itemdata.from[0].cid); cid = row.itemdata.from[0].cid; } else if (row.creatorcid) { picurl = FIRSTCLASS.util.User.getSmallProfPicUrlByCid(row.creatorcid); cid = row.creatorcid; } else { picurl = FIRSTCLASS.util.User.getSmallProfPicUrlByName(row.name); } return picurl; }, getProfilePictureUrl: function(row) { var picurl; var cid; if (row.itemdata && row.itemdata.from) { picurl = FIRSTCLASS.util.User.getSmallProfPicUrlByCid(row.itemdata.from[0].cid); cid = row.itemdata.from[0].cid; } else if (row.creatorcid) { picurl = FIRSTCLASS.util.User.getSmallProfPicUrlByCid(row.creatorcid); cid = row.creatorcid; } else { picurl = FIRSTCLASS.util.User.getSmallProfPicUrlByName(row.name); } return picurl; }, getSubElement: function(cfg) { if (cfg.renderer.descriptors) { var descriptor = cfg.renderer.descriptors[cfg.elementName]; if (descriptor) { return descriptor(cfg.element); } } return false; // return FIRSTCLASS.ui.Dom.getChildByClassName(cfg.elementName, cfg.element); } }; FIRSTCLASS.layout.Feed.templates = { initialized: false, fallback: { descriptors: { toolbar: function(table) { return table.childNodes[0].childNodes[4].childNodes[1]; } }, toolbar: ["acceptmember", "comment", "reply", "answer", "share","quote", "edit", "fcdelete", "flag", "dotag", "print"] }, byformid: { "20500": { description: "Blog Entry" }, "20501": { description: "Wiki Page" }, "20502": { description: "User Profile" /* should never be in a feed */ }, "20503": { description: "Document Wrapper", experimental: false, html: "
", descriptors: { profpic: function(element) { return element.childNodes[0]; }, toolbar: function(element) { return element.childNodes[2]; }, title: function(element) { return element.childNodes[1].childNodes[0]; }, body: function(element) { return element.childNodes[1].childNodes[1]; }, timestamp: function(element) { return element.childNodes[1].childNodes[2].firstChild; } }, toolbar: ["comment", "share", "edit", "fcdelete", "flag", "dotag", "print", 'sendto'], renderer: function(cfg) { FIRSTCLASS.layout.Feed.helpers.doCommonRenderActions(cfg); var title = this.descriptors.title(cfg.element.firstChild); var body = this.descriptors.body(cfg.element.firstChild); var timestamp = this.descriptors.timestamp(cfg.element.firstChild); var profpic = this.descriptors.profpic(cfg.element.firstChild); var titlehtml = ""+ FIRSTCLASS.layout.Feed.helpers.getVersionHTML(cfg.row) + ""; title.innerHTML = titlehtml; var bodyhtml = FIRSTCLASS.layout.Feed.helpers.getNameHTML(cfg.row); if (cfg.row.col8101) { bodyhtml += ": " + cfg.row.col8101; } if (cfg.row.linkinfo && cfg.row.linkinfo.lRepositoryReserved) { /* FIXME: NOT LOCALIZED */ bodyhtml += "
Reserved By: " + cfg.row.linkinfo.lRepositoryReservedBy; YAHOO.util.Dom.addClass(cfg.element, 'reserved'); } body.innerHTML = bodyhtml; YAHOO.util.Dom.setStyle(profpic, 'background-image', 'url(' + FIRSTCLASS.layout.Feed.helpers.getProfilePictureUrl(cfg.row) + ')'); timestamp.innerHTML = FIRSTCLASS.util.Date.getFriendlyDateTimeString(cfg.row.lastmods); } }, "20504": { description: "Workflow Wrapper", experimental: true, html: "
", descriptors: { icon: function(element) { return element.childNodes[0]; }, toolbar: function(element) { return element.childNodes[2]; }, title: function(element) { return element.childNodes[1].childNodes[0]; }, assignment: function(element) { return element.childNodes[1].childNodes[1].firstChild; }, initiatedby: function(element) { return element.childNodes[1].childNodes[1].childNodes[1]; }, status: function(element) { return element.childNodes[1].childNodes[1].childNodes[2]; } }, toolbar: ["showform"], renderer: function(cfg) { FIRSTCLASS.layout.Feed.helpers.doCommonRenderActions(cfg); var title = this.descriptors.title(cfg.element.firstChild); var initiatedby = this.descriptors.initiatedby(cfg.element.firstChild); var icon = this.descriptors.icon(cfg.element.firstChild); var assignment = this.descriptors.assignment(cfg.element.firstChild); var status = this.descriptors.status(cfg.element.firstChild); var addclass = ""; switch (cfg.row.options.priority) { case 0: /* normal */ addclass = 'normal'; break; case 1: /* urgent */ addclass = 'urgent'; break; case 2: /* bulk */ addclass = 'bulk'; break; case 3: /* junk */ addclass = 'junk'; break; } if (cfg.row.workflowstatus && cfg.row.workflowstatus.indexOf("ActivityLate") >= 0) { addclass = 'urgent'; } assignment.innerHTML = "assignment: " + cfg.row.stepname + ""; switch (cfg.row.lsubform) { case 0: case 1: /* assignments */ addclass += " assignment"; initiatedby.innerHTML = "initiated by: " + cfg.row.initiatedby; break; case 2: /* initiated */ addclass += " initiated"; initiatedby.innerHTML = "assigned to: " + cfg.row.assignedto; break; default: addclass += " initiated"; } if (addclass) { YAHOO.util.Dom.addClass(cfg.element.firstChild, addclass); } status.innerHTML = "" + cfg.row.workflowstatus + ""; title.innerHTML = cfg.row.workflowname; //YAHOO.util.Dom.setStyle(icon, 'background-image', 'url(' + FIRSTCLASS.layout.Feed.helpers.getProfilePictureUrl(cfg.row) + ')'); } }, "21000": { description: "Discussion Topic" }, "21001": { description: "Discussion Question" }, "21002": { description: "Discussion Reply", experimental: true, html: "
", descriptors: { profpic: function(element) { return element.childNodes[0]; }, toolbar: function(element) { return element.childNodes[2]; }, body: function(element) { return element.childNodes[1].childNodes[0]; }, timestamp: function(element) { return element.childNodes[1].childNodes[1].firstChild; } }, toolbar: ["quote", "reply", "share", "fcdelete", "flag", "dotag", "print"], renderer: function(cfg) { FIRSTCLASS.layout.Feed.helpers.doCommonRenderActions(cfg); var body = this.descriptors.body(cfg.element.firstChild); var timestamp = this.descriptors.timestamp(cfg.element.firstChild); var profpic = this.descriptors.profpic(cfg.element.firstChild); body.innerHTML = FIRSTCLASS.layout.Feed.helpers.getNameHTML(cfg.row) + " " + cfg.row.expandedPreview; YAHOO.util.Dom.setStyle(profpic, 'background-image', 'url(' + FIRSTCLASS.layout.Feed.helpers.getProfilePictureUrl(cfg.row) + ')'); timestamp.innerHTML = FIRSTCLASS.util.Date.getFriendlyDateTimeString(cfg.row.lastmods); } }, "21003": { description: "Comment", experimental: true, html: "
", descriptors: { profpic: function(element) { return element.childNodes[0]; }, toolbar: function(element) { return element.childNodes[2]; }, body: function(element) { return element.childNodes[1].childNodes[0]; }, timestamp: function(element) { return element.childNodes[1].childNodes[1].firstChild; } }, toolbar: ["quote", "comment", "share", "fcdelete", "flag", "dotag", "print"], renderer: function(cfg) { FIRSTCLASS.layout.Feed.helpers.doCommonRenderActions(cfg); var body = this.descriptors.body(cfg.element.firstChild); var timestamp = this.descriptors.timestamp(cfg.element.firstChild); var profpic = this.descriptors.profpic(cfg.element.firstChild); body.innerHTML = FIRSTCLASS.layout.Feed.helpers.getNameHTML(cfg.row) + " " + cfg.row.expandedPreview; YAHOO.util.Dom.setStyle(profpic, 'background-image', 'url(' + FIRSTCLASS.layout.Feed.helpers.getProfilePictureUrl(cfg.row) + ')'); timestamp.innerHTML = FIRSTCLASS.util.Date.getFriendlyDateTimeString(cfg.row.lastmods); } }, "21004": { description: "User Profile" }, "21005": { description: "Email Link Form" }, "21006": { description: "Request to Join Form", toolbar: ["acceptmember", "comment", "fcdelete", "flag", "dotag", "print"] }, "21007": { description: "OTSM IM Form", experimental: true, html: "
", descriptors: { profpic: function(element) { return element.childNodes[0]; }, toolbar: function(element) { return element.childNodes[2]; }, body: function(element) { return element.childNodes[1].childNodes[0]; }, timestamp: function(element) { return element.childNodes[1].childNodes[1].firstChild; } }, toolbar: ["quote", "reply", "share", "fcdelete", "flag", "dotag", "print"], renderer: function(cfg) { FIRSTCLASS.layout.Feed.helpers.doCommonRenderActions(cfg); var body = this.descriptors.body(cfg.element.firstChild); var timestamp = this.descriptors.timestamp(cfg.element.firstChild); var profpic = this.descriptors.profpic(cfg.element.firstChild); body.innerHTML = FIRSTCLASS.layout.Feed.helpers.getNameHTML(cfg.row) + " " + cfg.row.expandedPreview; YAHOO.util.Dom.setStyle(profpic, 'background-image', 'url(' + FIRSTCLASS.layout.Feed.helpers.getProfilePictureUrl(cfg.row) + ')'); timestamp.innerHTML = FIRSTCLASS.util.Date.getFriendlyDateTimeString(cfg.row.lastmods); } }, "21008": { description: "microblog", experimental: false, html: "
", descriptors: { profpic: function(element) { return element.childNodes[0]; }, toolbar: function(element) { return element.childNodes[2]; }, body: function(element) { return element.childNodes[1].childNodes[0]; }, timestamp: function(element) { return element.childNodes[1].childNodes[1].firstChild; } }, toolbar: ["reply", "fcdelete", 'fcdeselect'], renderer: function(cfg) { if (cfg.oldrow && cfg.oldrow.lastupdate == cfg.row.lastupdate) { return; } FIRSTCLASS.layout.Feed.helpers.doCommonRenderActions(cfg); var body = this.descriptors.body(cfg.element.firstChild); var timestamp = this.descriptors.timestamp(cfg.element.firstChild); var profpic = this.descriptors.profpic(cfg.element.firstChild); profpic.innerHTML = ""; // YAHOO.util.Dom.setStyle(profpic, 'background-image', 'url(' + FIRSTCLASS.layout.Feed.helpers.getTinyProfilePictureUrl(cfg.row) + ')'); var preview = ""; var nm = cfg.row.col8082; if (cfg.row.col1001) { nm = cfg.row.col1001; } var user = {"status": {}, "col8082": nm, "name": nm, "creatorcid": cfg.row.col1002}; if (typeof cfg.row.col1002 == "undefined") { user.creatorcid = cfg.row.creatorcid; } var userNameHTML = FIRSTCLASS.layout.Feed.helpers.getNameHTML(user, "") + " "; var invited = {"status": {}, "col8082": cfg.row.col1005, "name": cfg.row.col1005, "creatorcid": cfg.row.col1006}; var invitedNameHTML = ""; var titleText = ""; switch (cfg.row.lsubform) { case 1: // community creation titleText = " " + FIRSTCLASS.layout.Feed.helpers.getCommunityLinkHTML(cfg.row.col1003, cfg.row.col1004); preview = FIRSTCLASS.locale.doSub(FIRSTCLASS.locale.community.feed.microblog.createcommunity, {username: userNameHTML, communityname: titleText}); break; case 2: // new user invited to community titleText = " " + FIRSTCLASS.layout.Feed.helpers.getCommunityLinkHTML(cfg.row.col1003, cfg.row.col1004); invitedNameHTML = FIRSTCLASS.layout.Feed.helpers.getNameHTML(invited, ""); preview = FIRSTCLASS.locale.doSub(FIRSTCLASS.locale.community.feed.microblog.invited, {username: userNameHTML, invitedname: invitedNameHTML, communityname: titleText}); break; case 3: // new user's first login titleText = nm; preview = FIRSTCLASS.locale.doSub(FIRSTCLASS.locale.community.feed.microblog.loggedon + " ", {username: userNameHTML}); break; case 4:// new blog entry titleText = cfg.row.col1009; preview = FIRSTCLASS.locale.doSub(FIRSTCLASS.locale.community.feed.microblog.blogpost, {username: userNameHTML, blogname: "" + cfg.row.col1009 + ""}); break; case 0: // status update default: // also post titleText = cfg.row.expandedPreview; preview = FIRSTCLASS.locale.doSub(FIRSTCLASS.locale.community.feed.microblog.status, {username: userNameHTML, status: "" + cfg.row.expandedPreview + ""}); } // body.innerHTML = preview; FIRSTCLASS.ui.Dom.setInnerHTML(body,preview); //body.parentNode.parentNode.firstChild.setAttribute('title', 'reply to '+ titleText); /* if (cfg.row.icon.id == 9626) { YAHOO.util.Dom.addClass(cfg.element, 'music-update'); } else { YAHOO.util.Dom.addClass(cfg.element, 'status-update'); } */ timestamp.innerHTML = FIRSTCLASS.util.Date.getShortFriendlyDateTimeString(cfg.row.lastmods); } } }, bysubtype: { "33": { description: "person" }, "66": { description: "community" } }, byobjtype: { "3": { description: "confitem", useformid: 21000 }, "4": { description: "message", useformid: 21000 }, "6": { description: "file", useformid: 20503 }, "12": { description: "form", useformid: 20503 }, "17": { description: "formdoc", useformid: 20503 }, "22": { description: "document", useformid: 20501 }, "35": { description: "FCFile", useformid: 20503 }, "37": { description: "flagged item on desktop" } } }; FIRSTCLASS.layout.Feed.instances = 0; FIRSTCLASS.layout.Feed._rowTemplateDomElement = null; /** * the row draw function * * @Method Feed.createRow * @param {Object} row (required) the row to draw * @static */ FIRSTCLASS.layout.Feed.prototype.eventHandlers = { click: { approve: function(el, that, fcevent) { if (el && el.row && el.row.status.unapproved) { that._dataSource.approveItem(el.row); that.toolBar.reconfigure(el.row); } }, title: function(el, that, fcevent) { var docont = true; if (!FIRSTCLASS.session.safeToUnload({})) { if (!confirm(FIRSTCLASS.locale.desktop.navaway.prefix + "\n\n" + FIRSTCLASS.locale.desktop.navaway.editing + "\n\n" + FIRSTCLASS.locale.desktop.navaway.suffix)) { docont = true; } else if (FIRSTCLASS.session.getActiveApplication().overrideSafeToNavigate) { FIRSTCLASS.session.getActiveApplication().overrideSafeToNavigate(); docont = true; } else { docont = false; } } if (docont && that._config.headerClickFunc) { that._config.headerClickFunc(el.row); return true; } return false; }, less: function(el, that, fcevent) { var row = el.row; row.bitemdata = row.itemdata; row.itemdata = false; that._dataSource.notifyRowChanged(row, {status:row.status,itemdata:row.bitemdata}); that.listView.changeSelection(el.el, false, true, el.row); fcevent.target.innerHTML = FIRSTCLASS.locale.community.feed.more; }, more: function(el, that, fcevent) { var row = el.row; if (row.bitemdata) { row.itemdata = row.bitemdata; row.bitemdata = false; that._dataSource.notifyRowChanged(row, {status:row.status,itemdata:false}); } else { that._dataSource.fetchItem(row); } that.listView.changeSelection(el.el, false, true, el.row); fcevent.target.innerHTML = FIRSTCLASS.locale.community.feed.loading; }, reply: function(el, that, fcevent) { that.doFormAction(el.row, el.el, FIRSTCLASS.opCodes.Reply); }, answer: function(el, that, fcevent) { that.doFormAction(el.row, el.el, FIRSTCLASS.opCodes.Reply); }, comment: function(el, that, fcevent) { that.doFormAction(el.row, el.el, FIRSTCLASS.opCodes.Reply); }, sendto: function(el, that, fcevent) { var rgn = YAHOO.util.Dom.getRegion(fcevent.target); var xy = [rgn.left + rgn.width, rgn.top]; var config = { xy: xy, row: el.row, dataSource:that._dataSource, community: { uri: that._dataSource.getContainerUrl(), name: that._dataSource._data.name, cid: that._dataSource._data.cid, permalink: that._dataSource.getPermalink(that._selectedRow) } }; FIRSTCLASS.apps.Workflows.SendTo.start(config); }, /* sendtolivelink: function(el, that, fcevent) { if (FIRSTCLASS.session.ui.experimentalCheck()) { FIRSTCLASS.apps.Integration.ECM.Browse.doBrowse({ title:"Save " + el.row.name + " to LiveLink", fname:el.row.name, xuid: 2000, callbacks: { save: FIRSTCLASS.apps.Integration.ECM.Browse.Actions.put } }); } } */ fcdelete: function(el, that, fcevent) { if (el.row.typedef && (el.row.typedef.objtype == FIRSTCLASS.objTypes.odocument) && (el.row.lformid == 20503)) { if (confirm(FIRSTCLASS.locale.community.feed.deleteOrig)) { that._dataSource.deleteRow(el.row); } } else { that._dataSource.deleteRow(el.row); } }, fcdeselect: function(el, that, fcevent) { that.listView.changeSelection(false, false, true, false); FIRSTCLASS.ui.ToolbarPopup.closePopup(); }, feedwatch: function(el, that, fcevent) { that._dataSource.watchItem(el.row); el.row.watched = true; that.toolBar.reconfigure(el.row); }, feedunwatch: function(el, that, fcevent) { FIRSTCLASS.session.desktop.deleteWatch(el.row); el.row.watched = false; that.toolBar.reconfigure(el.row); }, dotag: function(el, that, fcevent) { that.doTagging(el.row, el.el); }, print: function(el, that, fcevent) { if (el.row.threadid == "0") { return false; } window.open(FIRSTCLASS.lang.ensureSlashUrl(FIRSTCLASS.session.domain + FIRSTCLASS.session._activeObject) + el.row.uri + "?Templates=Print"); }, feedrow: function(el, that, fcevent) { that.onRowClick(el.row, fcevent.target); return false; }, fcestart: function(el, that, fcevent) { var attrs = fcevent.fcattrs.split(";"); var url = FIRSTCLASS.lang.ensureSlashUrl(that._dataSource.getItemUrl(el.row,true,false,true)); url += "embed" + attrs[0] + ".html"; FIRSTCLASS.ui.embeds.handleClick(fcevent, url); }, editdoc: function(el, that, fcevent) { // first, create a holding element in the list view and load the plugin if it exists if (!that._pluginEl) { that._pluginEl = document.createElement("div"); that.listView._domElement.appendChild(that._pluginEl); if (FIRSTCLASS.ui.webdav.hasOfficePlugin()) { FIRSTCLASS.ui.webdav.loadOfficePlugin(that._pluginEl); } } if (that._pluginEl) { FIRSTCLASS.ui.webdav.edit(that._pluginEl, el.row, that._dataSource); } } }, mousedown: { quote: function(el, that, fcevent) { that.doFormAction(el.row, el.el, "Quote"); } }, mouseup: { feedrow: function(el, that, fcevent) { if (el.row !== that._selectedRow) { that.onRowClick(el.row, fcevent.target); } if (that._selectedRow && el.row.uri == that._selectedRow.uri) { that.checkSelect(); } return false; } }, keyup: { inlinereply: function(el, that, fcevent, jsevent) { if (jsevent.keyCode == 13 /* enter */) { /* post reply */ that.submitInlineReply(fcevent.target); return true; } YAHOO.util.Event.stopEvent(jsevent); } } }; FIRSTCLASS.layout.Feed.prototype.handleEvent = function(evt, fcevent) { var handlers = this.eventHandlers[evt.type]; if (handlers) { var handler = handlers[fcevent.fcid]; if (handler) { var el = this.findRowElement(evt); var rv = handler(el, this, fcevent, evt); if (typeof rv == "undefined") { rv = true; } return rv; } } }; FIRSTCLASS.layout.Feed.prototype.createRow = function(row) { var obj = FIRSTCLASS.layout.Feed.helpers.getTemplateObj(row, this._config); if (obj) { var myDomElement = document.createElement("div"); var table = obj.clone.firstChild.cloneNode(true); var html = "
"; myDomElement.innerHTML = html; myDomElement = myDomElement.firstChild; myDomElement.appendChild(table); this.updateRow(row, myDomElement); return myDomElement; } return this.createRowFallBack(row); }; FIRSTCLASS.layout.Feed.prototype.createRowFallBack = function(row) { var myDomElement = document.createElement("div"); //YAHOO.util.Dom.generateId(myDomElement); var table = FIRSTCLASS.layout.Feed._rowTemplateDomElement.firstChild.cloneNode(true); var html = "
"; myDomElement.innerHTML = html; myDomElement = myDomElement.firstChild; myDomElement.appendChild(table); this.updateRow(row, myDomElement); return myDomElement; }; FIRSTCLASS.layout.Feed.prototype.doWrap = function(_elem, m_elem, maxlength) { if (!m_elem) { m_elem = _elem; } if (!maxlength) { maxlength = 20; } var walker = document.createTreeWalker(_elem, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_ELEMENT, null, false); while (walker.nextNode()) { var node = walker.currentNode; if (node.nodeType == 3) { node.nodeValue = this.createBreakableWord(walker.currentNode, m_elem, maxlength); } else { node.className += ' wordwrap'; } } }; FIRSTCLASS.layout.Feed.prototype.createBreakableWord = function(_node, m_elem, maxlength) { var parent = _node.parentNode; var txt = _node.nodeValue; var words = txt.split(/\s/); var i, len = words.length; for (i = 0; i < len; i++) { var word = words[i]; var wordLen = word.length; if (word.length > maxlength) { word = word.split('').join(String.fromCharCode('8203')); } words[i] = word; } return words.join(' '); }; FIRSTCLASS.layout.Feed.prototype.adoWrap = function(elem) { var walker = document.createTreeWalker(elem, NodeFilter.SHOW_TEXT, null, false); while (walker.nextNode()) { var node = walker.currentNode; node.nodeValue = node.nodeValue.split('').join(String.fromCharCode('8203')); } }; FIRSTCLASS.layout.Feed.prototype.updateRow = function(row, element, oldRow) { var cfg = { row: row, oldrow: oldRow, element: element, dataSource: this._dataSource, feedconfig: this._config }; var obj = FIRSTCLASS.layout.Feed.helpers.getTemplateObj(row, this._config); if (obj) { return obj.renderer(cfg); } return FIRSTCLASS.layout.Feed.updateRowFallBack(cfg); }; FIRSTCLASS.layout.Feed.updateRowFallBack = function(cfg) { var row = cfg.row; var element = cfg.element; var oldrow = cfg.oldrow; var dataSource = cfg.dataSource; var config = cfg.feedconfig; var iconID, ext, p, itemUrl, i, img, html, bodyClass; /* FIXME: HACK FOR COOLSTUFF LIVE */ var specialClass = false; if (row.lformid == 21008) { if (row.icon.id == 9626) { specialClass = "microblog music-update"; } else { specialClass = "microblog status-update"; } } if (specialClass) { YAHOO.util.Dom.addClass(element, specialClass); } if (row.status.unread) { YAHOO.util.Dom.addClass(element, "unread"); } else { YAHOO.util.Dom.removeClass(element, "unread"); if (oldrow && oldrow.status.unread) { YAHOO.util.Dom.addClass(element, "recentlyread"); } } var showAttach = row.status.attachments && (row.col8010) && (row.col8010.indexOf("@") > 0); var table = element.firstChild; var imgDomElement = table.childNodes[0].childNodes[2].childNodes[1].childNodes[0].childNodes[0].childNodes[0].childNodes[0].childNodes[0]; var picurl = ""; var cid = false; var nm = row.name; if (row.col8082) { nm = row.col8082; } if (row.status.outgoing) { nm = FIRSTCLASS.session.user.name; } if (row.itemdata && row.itemdata.from) { picurl = FIRSTCLASS.util.User.getSmallProfPicUrlByCid(row.itemdata.from[0].cid); cid = row.itemdata.from[0].cid; } else if (row.creatorcid) { picurl = FIRSTCLASS.util.User.getSmallProfPicUrlByCid(row.creatorcid); cid = row.creatorcid; } else { picurl = FIRSTCLASS.util.User.getSmallProfPicUrlByName(nm); } if (row.status.unread) { var tackon = ""; if (row.lformid == 21008) { tackon = "&MaxWidthAA=33"; } YAHOO.util.Dom.setStyle(imgDomElement, 'background-image', "url("+picurl+tackon+")"); } else { YAHOO.util.Dom.setStyle(imgDomElement, 'background-image', ""); img = document.createElement("img"); img.src = picurl; if (!row.status.replicated) { img.setAttribute('fcid', 'user'); img.setAttribute('fcattrs', nm); if (cid) { img.setAttribute('uid', cid); } } YAHOO.util.Dom.addClass(img,'fclvrowprofpic'); YAHOO.util.Dom.removeClass(img, 'fclvrowpicunread'); imgDomElement.removeChild(imgDomElement.lastChild); imgDomElement.appendChild(img); } if (oldrow && oldrow.onlyunread) { return; } if (row.subject.indexOf("?") > 0 || (row.originalformid && row.originalformid == 143) || (row.originalformid && row.originalformid == 21001)) { YAHOO.util.Dom.addClass(element, 'fcMessageQuestion'); } else { YAHOO.util.Dom.removeClass(element, 'fcMessageQuestion'); } var messageDomElement = table.childNodes[0].childNodes[2].childNodes[1].childNodes[0].childNodes[0].childNodes[1].childNodes[0].childNodes[0]; YAHOO.util.Dom.addClass(messageDomElement,"fcMessageContents"); var rsDomElement = table.childNodes[0].childNodes[1].childNodes[2]; var headerDomElement = table.childNodes[0].childNodes[1].childNodes[1]; var toolBarDomElement = table.childNodes[0].childNodes[4].childNodes[1]; YAHOO.util.Dom.addClass(toolBarDomElement,"fcMessageToolBar"); var titleDomElement = table.childNodes[0].childNodes[2].childNodes[1].childNodes[0].childNodes[0].childNodes[0].childNodes[1].childNodes[0]; if (row.typedef.objtype == FIRSTCLASS.objTypes.file) { if (config.headerClickFunc) { titleDomElement.innerHTML = ""; titleDomElement = titleDomElement.firstChild; } if (row.typedef.searchhit) { titleDomElement.innerHTML = FIRSTCLASS.lang.mlesc(row.name); } else { if (row.col8090 && row.col8090 > 1) { titleDomElement.innerHTML = FIRSTCLASS.locale.community.feed.updated.replace("$name$", FIRSTCLASS.lang.mlesc(row.name)).replace("$version$", row.col8090); } else { titleDomElement.innerHTML = FIRSTCLASS.locale.community.feed.uploaded.replace("$name$", FIRSTCLASS.lang.mlesc(row.name)); } } } else if(row.typedef.objtype == FIRSTCLASS.objTypes.odocument || row.typedef.objtype == FIRSTCLASS.objTypes.oformdoc) { if (config.headerClickFunc) { titleDomElement.innerHTML = ""; titleDomElement = titleDomElement.firstChild; } if (row.typedef.searchhit) { titleDomElement.innerHTML = row.name; } else { if (row.col8090 && row.col8090 > 1) { titleDomElement.innerHTML = FIRSTCLASS.locale.community.feed.updated.replace("$name$", FIRSTCLASS.lang.mlesc(row.name)).replace("$version$", row.col8090); } else { titleDomElement.innerHTML = FIRSTCLASS.locale.community.feed.created.replace("$name$", FIRSTCLASS.lang.mlesc(row.name)); } } } else { /* FIXME: HACK FOR COOLSTUFF LIVE */ if (row.lformid == 21008) { YAHOO.util.Dom.setStyle(titleDomElement.parentNode, 'padding-left', '10px'); YAHOO.util.Dom.setStyle(titleDomElement, 'margin-left', '0px'); titleDomElement.innerHTML = "
 " + row.expandedPreview; } else { titleDomElement.innerHTML = FIRSTCLASS.util.expandHashTags(FIRSTCLASS.lang.mlesc(row.subject).parseURLS()); // FIXME: only to get integration stuff working if (row.subject === "" && row.col14) { titleDomElement.innerHTML = FIRSTCLASS.lang.mlesc(row.col14); } } } if (row.tags && row.tags.length > 0 && !element.tagger) { var tagContainer = table.childNodes[0].childNodes[3].childNodes[1].childNodes[0]; tagContainer.innerHTML = "" + FIRSTCLASS.locale.community.feed.tags + "" + FIRSTCLASS.ui.generateCloud(FIRSTCLASS.ui.parseServerTags(row.tags)) + ""; } var nameDomElement = table.childNodes[0].childNodes[2].childNodes[1].childNodes[0].childNodes[0].childNodes[0].childNodes[1].lastChild.childNodes[0]; if (row.lformid == 21008) { nameDomElement = titleDomElement.firstChild; var commaDomElement = table.childNodes[0].childNodes[2].childNodes[1].childNodes[0].childNodes[0].childNodes[0].childNodes[1].lastChild.childNodes[1]; YAHOO.util.Dom.setStyle(commaDomElement, 'display', 'none'); } nameDomElement.innerHTML = FIRSTCLASS.layout.Feed.helpers.getNameHTML(row); var dateDomElement = table.childNodes[0].childNodes[2].childNodes[1].childNodes[0].childNodes[0].childNodes[0].childNodes[1].lastChild.lastChild; dateDomElement.innerHTML = ""; switch(FIRSTCLASS.util.Date.getFriendlyDateString(row.lastmods)) { case FIRSTCLASS.locale.Date.today: case FIRSTCLASS.locale.Date.yesterday: break; default: dateDomElement.innerHTML = FIRSTCLASS.locale.Date.on + " "; } dateDomElement.innerHTML += FIRSTCLASS.util.Date.getFriendlyDateTimeString(row.lastmods); html = []; if (row.subject.indexOf("FAX") === 0) { YAHOO.util.Dom.setStyle(rsDomElement, "background-image", "url(" + FIRSTCLASS.session.ui.fcbase.absolute + "/images/Fax_icon_32x32.png)"); //imgDomElement.src = '' } else if (row.subject.indexOf("Voice Message") === 0) { YAHOO.util.Dom.setStyle(rsDomElement, "background-image", "url(" + FIRSTCLASS.session.ui.fcbase.absolute + "/images/Phone_32x32.png)"); } else if(row.typedef && row.typedef.objtype == FIRSTCLASS.objTypes.odocument) { if (config.thumbnailClickLoadsItem && row.linkinfo && (row.linkinfo.url || row.lformid == 20503)) { p = rsDomElement; p.innerHTML = ""; itemUrl = ""; if (row.linkinfo && row.linkinfo.url) { itemUrl = row.linkinfo.url.substr(1); } else { itemUrl = FIRSTCLASS.lang.ensureSlashUrl(dataSource.getContainerUrl()) + row.uri; } p.firstChild.href = itemUrl; p.firstChild.target = "_new"; rsDomElement = p.firstChild.firstChild; if (row.icon.id == 70) { YAHOO.util.Dom.setStyle(rsDomElement, "background-image", "url(/Icons/" + iconID + ")"); rsDomElement.src = "/Icons/70"; } else { rsDomElement.src = "/Icons/" + iconID; } } else { var iconuri = ""; if (row.lformid == 20503) { iconID = false; ext = "" + row.name; ext = ext.slice(ext.lastIndexOf(".") + 1); ext = ext.toLowerCase(); if (ext) { iconID = FIRSTCLASS.fileTypeIcons[ext]; } if (iconID === undefined) { iconID = 9620; } iconuri = "/Icons/" + iconID; } else { iconuri = FIRSTCLASS.session.ui.fcbase.absolute + "/images/wiki.png"; } YAHOO.util.Dom.setStyle(rsDomElement, "background-image", "url(" + iconuri + ")"); } } else if(row.typedef && row.typedef.objtype == FIRSTCLASS.objTypes.file /* FIXME: hack to get integration stuff working*/ || row.icon.id == 70) { ext = "" + row.name; ext = ext.slice(ext.lastIndexOf(".") + 1); ext = ext.toLowerCase(); iconID = 9620; if (row.col8065) { // got a thumbnail if (config.thumbnailClickLoadsItem) { p = rsDomElement; p.innerHTML = ""; itemUrl = ""; if (row.linkinfo && row.linkinfo.url) { itemUrl = row.linkinfo.url.substr(1); } else { itemUrl = FIRSTCLASS.lang.ensureSlashUrl(dataSource.getContainerUrl()) + row.uri; } p.firstChild.href = itemUrl; p.firstChild.target = "_new"; rsDomElement = p.firstChild.firstChild; rsDomElement.src = dataSource.getContainerUrl() + row.col8065; } else { YAHOO.util.Dom.setStyle(rsDomElement, "background-image", "url(" + dataSource.getContainerUrl() + row.col8065 + ")"); } } else { if (ext) { iconID = FIRSTCLASS.fileTypeIcons[ext]; } if (iconID === undefined) { iconID = 9620; } if (config.thumbnailClickLoadsItem) { p = rsDomElement; p.innerHTML = ""; itemUrl = ""; if (row.linkinfo && row.linkinfo.url) { itemUrl = row.linkinfo.url.substr(1); } else { itemUrl = FIRSTCLASS.lang.ensureSlashUrl(dataSource.getContainerUrl()) + row.uri; } p.firstChild.href = itemUrl; p.firstChild.target = "_new"; rsDomElement = p.firstChild.firstChild; if (row.icon.id == 70) { YAHOO.util.Dom.setStyle(rsDomElement, "background-image", "url(/Icons/" + iconID + ")"); rsDomElement.src = "/Icons/70"; } else { rsDomElement.src = "/Icons/" + iconID; } } else { YAHOO.util.Dom.setStyle(rsDomElement, "background-image", "url(/Icons/" + iconID + ")"); } } } else if (row.subject.indexOf("?") < 0) { YAHOO.util.Dom.setStyle(rsDomElement, 'display', 'none'); YAHOO.util.Dom.setStyle(rsDomElement, 'width', '0px'); } if (!YAHOO.env.ua.ie) { YAHOO.util.Dom.setStyle(rsDomElement, "opacity", "0.6"); } var updatemessage = false; var slhtml = "
"+nameDomElement.innerHTML+" 
"; var bodyclass = "fcBody"; var bodyhtml = ""; var footer = ""; if(row.col8101 || row.col8090) { var version = ""; if (row.col8090) { version = FIRSTCLASS.locale.community.feed.version.doSub([row.col8090]); } if (row.col8090 && row.col8101) { version += ": " + FIRSTCLASS.lang.mlesc(row.col8101); } else if (row.col8101) { version += FIRSTCLASS.lang.mlesc(row.col8101); /* FIXME: only to get integration stuff working */ } if (row.status.unapproved) { /* FIXME: ONLY FOR HRDC RFP */ if (navigator.language.indexOf("fr") >= 0) { version += " (NĂ©cessite l'approbation)"; } else { version += " (Requires Approval)"; } } if (row.icon.id == 70 && row.expandedPreview) { version += "
"; bodyhtml = row.expandedPreview; } bodyClass = "fcBody"; slhtml += version; updatemessage = true; } else if (row.itemdata) { if (!oldrow || !oldrow.itemdata || row.itemdata.expandedBody != oldrow.itemdata.expandedBody) { bodyclass = 'fcBody'; if (row.subject.indexOf("FAX") === 0) { bodyclass += " fcFax"; } bodyhtml = row.itemdata.expandedBody; YAHOO.util.Dom.addClass(element, "bodyexpanded"); if (showAttach && row.itemdata.attachments && row.itemdata.attachments.length) { var thtml = []; thtml.push(""); for (i = 0; i < row.itemdata.attachments.length; i++) { thtml.push(""); } thtml.push("
Attachments
" + row.itemdata.attachments[i].name + "" + row.itemdata.attachments[i].size + "
"); footer = thtml.join(""); } updatemessage = true; } } else if(row.col8063 && row.col8063 != "") { bodyhtml = row.expandedPreview; /* FIXME: HACK FOR COOLSTUFF LIVE */ if (row.lformid == 21008) { bodyhtml = ""; } } else if (row.status.unapproved) { /* FIXME: HACK FOR HRDC RFP */ bodyhtml = "This message has not been approved"; if (FIRSTCLASS.permissions.hasPriv(row.acl, FIRSTCLASS.permissions.ACL.APPROVE)) { bodyhtml += ",
click here to view it before approving"; } else { bodyhtml += "."; } } else { updatemessage = true; } var modifier = ""; if (row.itemdata || !row.status.complete && (row.typedef.objtype == FIRSTCLASS.objTypes.message || row.typedef.objtype == FIRSTCLASS.objTypes.confitem) && !row.status.unapproved || showAttach) { var fcid = 'more'; var str = FIRSTCLASS.locale.community.feed.more; if (row.itemdata) { fcid = "less"; str = FIRSTCLASS.locale.community.feed.less; } else if (row.status.complete && row.status.attachments) { str = FIRSTCLASS.locale.community.feed.attachments; } modifier = ""; } html.push("
", slhtml, bodyhtml, modifier, footer, "
"); if(row.col15) { html.push("
"); html.push(FIRSTCLASS.locale.community.feed.infolder); html.push(row.col15.substr(1, row.col15.length-2)); html.push("
"); } if (html.length) { messageDomElement.innerHTML = html.join(""); var imgs = messageDomElement.getElementsByTagName("IMG"); for (i = 0; i < imgs.length; i++) { img = imgs[i]; YAHOO.util.Dom.setStyle(img, "height", "auto"); } } /* var moreitem = FIRSTCLASS.ui.Dom.getChildByClassName("fcSingleLineMore", messageDomElement); if (row.itemdata && false) { YAHOO.util.Dom.setStyle(messageDomElement.firstChild.firstChild, 'margin', null); YAHOO.util.Dom.setStyle(messageDomElement.firstChild.firstChild, 'margin-left', '10px'); } if ((YAHOO.env.ua.gecko || YAHOO.env.ua.webkit) && false) { var fcbody = FIRSTCLASS.ui.Dom.getChildByClassName('fcBody', messageDomElement, 0); if (fcbody) { this.doWrap(fcbody); } }*/ }; FIRSTCLASS.layout.Feed.prototype.doTagging = function (row, element) { var tagContainer, obj; if (element.tagger) { FIRSTCLASS.apps.Workflows.Tags.cleanup(); if (element.formElement) { YAHOO.util.Event.purgeElement(element.formElement, true); element.formElement.parentNode.removeChild(element.formElement); element.formElement = false; } if (element.message) { element.message = false; } element.tagger = false; if (row.tags && row.tags.length > 0) { obj = FIRSTCLASS.layout.Feed.helpers.getTemplateObj(row, this._config); if (obj) { tagContainer = FIRSTCLASS.layout.Feed.helpers.getSubElement({elementName:"toolbar", element: element.firstChild, renderer: obj}).lastChild; } else { tagContainer = FIRSTCLASS.ui.Dom.getChildByClassName('fcFeedTags', element); } tagContainer.innerHTML = "" + FIRSTCLASS.locale.community.feed.tags + "" + row.tags + ""; } } else { obj = FIRSTCLASS.layout.Feed.helpers.getTemplateObj(row, this._config); if (obj) { tagContainer = FIRSTCLASS.layout.Feed.helpers.getSubElement({elementName:"toolbar", element: element.firstChild, renderer: obj}).lastChild; } else { tagContainer = FIRSTCLASS.ui.Dom.getChildByClassName('fcFeedTags', element); } var tags = document.createElement("div"); var that = this; if (element.formElement) { YAHOO.util.Event.purgeElement(element.formElement, true); element.formElement.parentNode.removeChild(element.formElement); element.formElement = false; } if (element.message) { element.message = false; } tagContainer.innerHTML = ""; tagContainer.appendChild(tags); YAHOO.util.Dom.addClass(tags,'fcFeedTagger'); element.formElement = tags; var config = { domElement:tags, item: FIRSTCLASS.ui.parseServerTags(row.tags), personal:FIRSTCLASS.session.desktop.personaltags, container: FIRSTCLASS.ui.parseServerTags(this._dataSource.getTags()), editable: true, dataSource: this._dataSource, row: row, showonconfig:true }; element.tagger = true; FIRSTCLASS.apps.Workflows.Tags.reconfigure(config); } }; FIRSTCLASS.layout.Feed.prototype.doFormAction = function(row, element, actionURI) { var theTime = new Date(); if (this.lastFormActionTime && theTime - this.lastFormActionTime < 500) { return; } var that = this; this.listView.changeSelection(element, false, true, row); var url = FIRSTCLASS.lang.ensureSlashUrl(this._dataSource.getItemUrl(row)); var action = actionURI; if (actionURI == "Quote") { action = FIRSTCLASS.opCodes.Reply; } var formID = 141; var addr = true; var params = ""; var tbtype = "message"; if (action == FIRSTCLASS.opCodes.Reply) { if (!FIRSTCLASS.permissions.hasPriv(this._dataSource.getAcl(), FIRSTCLASS.permissions.ACL.SEND)) { params += "Type=Sender&"; } params += "Quote=0&InitialText="; formID = 21002; addr = false; tbtype = "reply"; } if (this._config.inlineReplyFormID) { formID = this._config.inlineReplyFormID; } // set up node to receive the new item var child = FIRSTCLASS.ui.Dom.getChildByClassName("fclvrowformdoc", element); YAHOO.util.Dom.removeClass(child, 'fcHidden'); YAHOO.util.Dom.setStyle(child, 'height', ''); YAHOO.util.Dom.setStyle(child, 'background', ''); var hadForm = false; var createForm = true; if (element.formElement) { if (actionURI == "Quote" && (element.lastActionURI == FIRSTCLASS.opCodes.Reply || element.lastActionURI == "Quote") && this._selection && element.message) { // send a quote into the editor createForm = false; var quoteAuth = row.name; if (row.col8082) { quoteAuth = row.col8082; } element.message.insertQuote(this._selection, quoteAuth); } else { hadForm = true; try { this.clearForm(element); } catch(e) { } } } if (createForm && (hadForm && element.lastActionURI != actionURI || !hadForm)) { var elem = document.createElement("div"); element.formElement = elem; child.appendChild(elem); /* create the message */ var bodyType = "HTML"; if (this._config.bodyType) { bodyType = this._config.bodyType; } var msgCfg = { callback: { onFail: function(obj) { var html = ""; if (obj && obj.error) { FIRSTCLASS.ui.navBar.updateShoutBox(FIRSTCLASS.locale.errors.getErrorString(obj.error)); } that.clearForm(element, html); }, onCancel: function () { that.clearForm(element); }, onSave: function () { that.clearForm(element); that._dataSource.fetchNewRows(); }, onDisplay: function() { if (bodyType === "HTML") { if (element.message._editor) { element.message._editor.focus(); } } else { if (element.message && element.message._editForm && element.message._editForm.BODY) { element.message._editForm.BODY.focus(); } } } }, element: elem, op: action, params: params, baseURL: url, objType: FIRSTCLASS.objTypes.message, formID: formID, formElId: "fcDocForm", bodyType: bodyType, quoteText: null, sendTo: null, tbType: tbtype, initHeight: "200px", autoHeight: true, showAddr: addr, maxImage: 320 }; if (YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 7 && this._config.bodyType != "plain") { msgCfg.callback.onDisplay = function() { var rgn = YAHOO.util.Dom.getRegion(child); that.listView.scrollTo(rgn.top); that.listView.disableScroll(); }; } if (actionURI == "Quote") { if (this._selection) { msgCfg.quoteText = this._selection; } msgCfg.quoteAuth = row.name; if (row.col8082) { msgCfg.quoteAuth = row.col8082; } } element.message = new FIRSTCLASS.util.Message(msgCfg); this.setEditorActive(); element.lastActionURI = actionURI; this._selection = false; } this.lastFormActionTime = theTime; }; FIRSTCLASS.layout.Feed.prototype.setForm = function(elem, node) { var that = this; }; FIRSTCLASS.layout.Feed.prototype.clearForm = function(node, replacementhtml) { this.clearEditorActive(); if (node.message) { node.message.destroy(); node.message = false; } if (!replacementhtml) { replacementhtml = ""; } if (node.formElement) { YAHOO.util.Event.purgeElement(node.formElement, true); var child = FIRSTCLASS.ui.Dom.getChildByClassName("fclvrowformdoc", node); child.innerHTML = replacementhtml; YAHOO.util.Dom.setStyle(child, 'background', 'transparent'); YAHOO.util.Dom.setStyle(child, 'height', '0px'); YAHOO.util.Dom.addClass(child, 'fcHidden'); node.formElement = false; } if (YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 7 && this._config.bodyType != "plain") { this.listView.allowScroll(); } }; FIRSTCLASS.layout.Feed.prototype.setEditorActive = function() { this.hasEditorActive = true; this.listView.suspendSelection(); }; FIRSTCLASS.layout.Feed.prototype.clearEditorActive = function() { this.hasEditorActive = false; this.listView.enableSelection(); }; FIRSTCLASS.layout.Feed.prototype.onRowClick = function(row, domElement) { this.listView.changeSelection(domElement, false, true, row); }; FIRSTCLASS.layout.Feed.prototype.checkSelect = function() { this._selection = FIRSTCLASS.ui.getSelection(); this.toolBar.reconfigure(this._selectedRow); }; FIRSTCLASS.layout.Feed.prototype.insertQuote = function(quote, author) { if (FIRSTCLASS.layout.Feed.submitInlineReplyCallBacks._form) { var body = FIRSTCLASS.layout.Feed.submitInlineReplyCallBacks._form.elements['BODY']; body.focus(); body.value = author + " said:\n\"" + quote + "\"\n\n"; YAHOO.util.Dom.setStyle(body, 'height', '70px'); } }; FIRSTCLASS.layout.Feed.prototype.insertInlineReply = function(tbcontainer, row) { if (typeof this._config.allowReplies == "undefined" || this._config.allowReplies === true) { var container = tbcontainer.childNodes[1]; var html = []; html.push("
"); html.push(""); html.push(""); html.push(""); html.push(""); html.push(""); if (this._config.inlineReplyIcon) { html.push(""); } if (this._config.inlineReplyFormID) { html.push(""); } html.push(""); html.push(""); html.push("
"); container.innerHTML = html.join(""); if (this._config.inlineReplyFormID) { container.firstChild.action = container.firstChild.action + "&FormID="+ this._config.inlineReplyFormID; } container.firstChild.elements["BODY"].focus(); FIRSTCLASS.layout.Feed.submitInlineReplyCallBacks._form = container.firstChild; } }; FIRSTCLASS.layout.Feed.prototype.clearInlineReply = function(tbcontainer) { tbcontainer.childNodes[1].innerHTML = ""; }; FIRSTCLASS.layout.Feed.prototype.submitInlineReply = function(form) { if (form.elements["BODY"].value != "") { FIRSTCLASS.layout.Feed.submitInlineReplyCallBacks._form = form; FIRSTCLASS.util.submitForm(form, false, FIRSTCLASS.layout.Feed.submitInlineReplyCallBacks); } }; FIRSTCLASS.layout.Feed.submitInlineReplyCallBacks = { success: function(response) { if (this._form) { var body = this._form.elements['BODY']; body.value = "Sent..."; body.blur(); } }, failure: function(response) { if (this._form) { var body = this._form.elements['BODY']; body.value = 'Failed, please try again'; body.blur(); } } }; FIRSTCLASS.layout.Feed.prototype.onSelectionChange = function(from, to, torow, fromrow) { this._selection = false; if (from && from.tagger) { FIRSTCLASS.apps.Workflows.Tags.cleanup(); from.tagger = false; } var that = this, tbcontainer, obj, row; this._selectedRow = torow; this._selectedElement = to; if (!this._tbStorage) { this._tbStorage = document.createElement("div"); } FIRSTCLASS.ui.Dom.reparentNode(this.toolBarDomElement, this._tbStorage); if (from) { tbcontainer = false; obj = FIRSTCLASS.layout.Feed.helpers.getTemplateObj(fromrow, this._config); if (obj) { tbcontainer = FIRSTCLASS.layout.Feed.helpers.getSubElement({elementName:"toolbar", element: from.firstChild, renderer: obj}); } if (!tbcontainer) { try { tbcontainer = from.firstChild.firstChild.childNodes[4].childNodes[1]; } catch (e) { tbcontainer = FIRSTCLASS.ui.Dom.getChildByClassName(from, 'fclvrowtoolbar'); } } tbcontainer.innerHTML = "
"; this.clearInlineReply(tbcontainer); } if (to) { tbcontainer = false; row = fromrow; obj = FIRSTCLASS.layout.Feed.helpers.getTemplateObj(torow, this._config); if (obj) { tbcontainer = FIRSTCLASS.layout.Feed.helpers.getSubElement({elementName:"toolbar", element: to.firstChild, renderer: obj}); } if (!tbcontainer) { try { tbcontainer = to.firstChild.firstChild.childNodes[4].childNodes[1]; } catch (e2) { tbcontainer = FIRSTCLASS.ui.Dom.getChildByClassName(to, 'fclvrowtoolbar'); } } //var tbcontainer = to.firstChild.firstChild.childNodes[4].childNodes[1]; if (tbcontainer) { tbcontainer.innerHTML = ""; FIRSTCLASS.ui.Dom.reparentNode(this.toolBarDomElement, tbcontainer); var node = document.createElement("div"); YAHOO.util.Dom.addClass(node, 'fcInlineReply'); this.toolBarDomElement.parentNode.appendChild(node); this.toolBar.reconfigure(torow); } if (!YAHOO.util.Dom.hasClass(to, 'recentlyread')) { YAHOO.util.Dom.addClass(to, "recentlyread"); } /* FIXME:COMMENTED OUT FOR RFP this.insertInlineReply(tbcontainer, torow);*/ } if (this._selectedRow) { this.toolBar.reconfigure(this._selectedRow); } }; FIRSTCLASS.layout.Feed.prototype.generateUniqueId = function(row) { return row.messageid; }; FIRSTCLASS.layout.Feed.prototype.setListView = function(listView) { this.listView = listView; }; YAHOO.register("fcFeed", FIRSTCLASS.layout.Feed, {version: "0.0.1", build: "1"});