/** * Class Description * @namespace FIRSTCLASS.layout * @module Feed * @requires * @optional * @title Feed Application */ /** * Constructor definition * @class Feed * @constructor * @param {} * @param ... */ FIRSTCLASS.layout.Feed = function(config) { 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); } }; var that = this; this.toolBarButtonCfg = { domElement:this.toolBarDomElement, buttons: [ { id: "fcFeedAcceptMember" + this.instance, label: FIRSTCLASS.locale.workflows.acceptmember.accept, fcid: 'acceptmember', condition: function(row) { 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) { //html.push(""); el.setAttribute('fcattrs', that._selectedRow.creatorcid); } } }, { id: "fcFeedReply" + this.instance, label: FIRSTCLASS.locale.toolbars.feed.reply, fcid: "reply", condition: function(row) { 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.threadid != "0"; } }, { id: "fcFeedAnswer" + this.instance, label: FIRSTCLASS.locale.toolbars.feed.answer, fcid: 'answer', condition: function(row) { 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"; } }, { id: "fcFeedQuote" + this.instance, label: FIRSTCLASS.locale.toolbars.feed.quote, fcid: 'quote', condition: function(row) { if (YAHOO.env.ua.ie && YAHOO.env.ua.ie < 8) { return false; } else { 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) { 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.threadid != "0"; } }, { id: "fcFeedEdit" + this.instance, label: FIRSTCLASS.locale.toolbars.feed.edit, fcid: 'editdoc', condition: function(row) { 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: "fcFeedSendTo" + this.instance, label: FIRSTCLASS.locale.toolbars.feed.sendto, fcid: 'sendto', condition: function(row) { return row.threadid != "0"; } }, { id: "fcFeedDelete"+ this.instance, label: FIRSTCLASS.locale.toolbars.feed.del, fcid: 'fcdelete', condition: function(row) { 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) { 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: 'unwatch', condition: function(row) { 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) { return row.threadid != "0";// FIRSTCLASS.permissions.hasPriv(row.acl, FIRSTCLASS.permissions.ACL.EDITWINFO); } }, { id: "fcFeedPrint" + this.instance, label: FIRSTCLASS.locale.toolbars.feed.print, fcid: 'print' }, { id: "fcFeedPermaLink" + this.instance, label: FIRSTCLASS.locale.toolbars.feed.permalink, fcid: 'permalink', customizer: function(el) { if (that._selectedRow) { var l = FIRSTCLASS.locale.toolbars.feed.permalink; var ls = l.split("|"); if (ls.length == 1) { ls[1] = ""; } el.innerHTML = ""+ls[0]+""; } } } ]}; this.toolBar = new FIRSTCLASS.ui.toolBar(this.toolBarButtonCfg); }; 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: { 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.draw(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) { that._dataSource.deleteRow(el.row); }, feedwatch: function(el, that, fcevent) { that._dataSource.watchItem(el.row); el.row.watched = true; that.toolBar.reconfigure(el.row); }, unwatch: 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.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 (that._selectedRow && el.row.uri == that._selectedRow.uri) { that.checkSelect(); } } } }; 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); if (typeof rv == "undefined") { rv = true; } return rv; } } }; FIRSTCLASS.layout.Feed.prototype.createRow = 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) { 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.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) { YAHOO.util.Dom.setStyle(imgDomElement, 'background-image', "url("+picurl+")"); } else { YAHOO.util.Dom.setStyle(imgDomElement, 'background-image', ""); var 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 (this._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 (this._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.created.replace("$name$", FIRSTCLASS.lang.mlesc(row.name)); } } } else { titleDomElement.innerHTML = FIRSTCLASS.lang.mlesc(row.subject); // 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]; var html = []; if (row.creatorcid && !row.status.replicated) { html.push("
 "); } else if (row.creatorcid) { html.push("
 "); } else { html.push(""); nameDomElement.innerHTML = html.join(""); 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.templatebase + "/firstclass/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.templatebase + "/firstclass/images/Phone_32x32.png)"); } else if(row.typedef && row.typedef.objtype == FIRSTCLASS.objTypes.odocument) { if (this._config.thumbnailClickLoadsItem && row.linkinfo && row.linkinfo.url) { var p = rsDomElement; p.innerHTML = ""; var itemUrl = ""; if (row.linkinfo && row.linkinfo.url) { itemUrl = row.linkinfo.url.substr(1); } else { itemUrl = FIRSTCLASS.lang.ensureSlashUrl(this._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(" + FIRSTCLASS.session.templatebase + "/firstclass/images/wiki.png)"); } } else if(row.typedef && row.typedef.objtype == FIRSTCLASS.objTypes.file /* FIXME: hack to get integration stuff working*/ || row.icon.id == 70) { var ext = "" + row.name; ext = ext.slice(ext.lastIndexOf(".") + 1); ext = ext.toLowerCase(); var iconID = 9620; if (row.col8065) { // got a thumbnail if (this._config.thumbnailClickLoadsItem) { var p = rsDomElement; p.innerHTML = ""; var itemUrl = ""; if (row.linkinfo && row.linkinfo.url) { itemUrl = row.linkinfo.url.substr(1); } else { itemUrl = FIRSTCLASS.lang.ensureSlashUrl(this._dataSource.getContainerUrl()) + row.uri; } p.firstChild.href = itemUrl; p.firstChild.target = "_new"; rsDomElement = p.firstChild.firstChild; rsDomElement.src = this._dataSource.getContainerUrl() + row.col8065; } else { YAHOO.util.Dom.setStyle(rsDomElement, "background-image", "url(" + this._dataSource.getContainerUrl() + row.col8065 + ")"); } } else { if (ext) { iconID = FIRSTCLASS.fileTypeIcons[ext]; } if (iconID == undefined) { iconID = 9620; } if (this._config.thumbnailClickLoadsItem) { var p = rsDomElement; p.innerHTML = ""; var itemUrl = ""; if (row.linkinfo && row.linkinfo.url) { itemUrl = row.linkinfo.url.substr(1); } else { itemUrl = FIRSTCLASS.lang.ensureSlashUrl(this._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 = "Version " + 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.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 (var 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; } else { updatemessage = true; } var modifier = ""; if (row.itemdata || !row.status.complete && (row.typedef.objtype == FIRSTCLASS.objTypes.message || row.typedef.objtype == FIRSTCLASS.objTypes.confitem) || showAttach) { var that = this; 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 (var i = 0; i < imgs.length; i++) { var 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) { 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) { var tagContainer = FIRSTCLASS.ui.Dom.getChildByClassName('fcFeedTags', element); tagContainer.innerHTML = "" + FIRSTCLASS.locale.community.feed.tags + "" + row.tags + ""; } } else { var 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"; }; // set up node to receive the new item var child = FIRSTCLASS.ui.Dom.getChildByClassName("fclvrowformdoc", element); 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 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(); } }, element: elem, op: action, params: params, baseURL: url, objType: FIRSTCLASS.objTypes.message, formID: formID, formElId: "fcDocForm", bodyType: "HTML", quoteText: null, sendTo: null, tbType: tbtype, initHeight: 240, autoHeight: true, showAddr: addr, maxImage: 320 }; if (YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 7) { 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'); node.formElement = false; } if (YAHOO.env.ua.ie <= 7) { 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.onSelectionChange = function(from, to, torow) { this._selection = false; if (from && from.tagger) { FIRSTCLASS.apps.Workflows.Tags.cleanup(); from.tagger = false; } var that = this; this._selectedRow = torow; this._selectedElement = to; if (!this._tbStorage) { this._tbStorage = document.createElement("div"); } FIRSTCLASS.ui.Dom.reparentNode(this.toolBarDomElement, this._tbStorage); if (from) { var tbcontainer = from.firstChild.firstChild.childNodes[4].childNodes[1]; tbcontainer.innerHTML = "
"; } if (to) { var tbcontainer = to.firstChild.firstChild.childNodes[4].childNodes[1]; if (tbcontainer) { tbcontainer.innerHTML = ""; FIRSTCLASS.ui.Dom.reparentNode(this.toolBarDomElement, tbcontainer); this.toolBar.reconfigure(torow); } if (!YAHOO.util.Dom.hasClass(to, 'recentlyread')) { YAHOO.util.Dom.addClass(to, "recentlyread"); } } 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"});