/** * Class Description * @namespace FIRSTCLASS.layout * @module BlogFeed * @requires * @optional * @title BlogFeed Application */ /** * Constructor definition * @class BlogFeed * @constructor * @param {} * @param ... */ FIRSTCLASS.layout.BlogFeed = function(config) { this.instance = FIRSTCLASS.layout.BlogFeed.instances++; var that = this; var template = []; if (!FIRSTCLASS.layout.BlogFeed._rowDocTemplateDomElement) { FIRSTCLASS.layout.BlogFeed._rowDocTemplateDomElement = document.createElement("div"); var docTemplate = []; docTemplate.push(""); docTemplate.push(""); docTemplate.push(""); docTemplate.push(""); docTemplate.push(""); docTemplate.push(""); docTemplate.push(""); docTemplate.push(""); docTemplate.push("

"); docTemplate.push(""); docTemplate.push(""); docTemplate.push("
" + FIRSTCLASS.locale.blog.postedby + "
"); docTemplate.push("
"); FIRSTCLASS.layout.BlogFeed._rowDocTemplateDomElement.innerHTML = docTemplate.join(""); } if (!FIRSTCLASS.layout.BlogFeed._rowReplyTemplateDomElement) { FIRSTCLASS.layout.BlogFeed._rowReplyTemplateDomElement = document.createElement("div"); template = []; template.push(""); template.push(""); template.push(""); template.push("
, "); template.push("
"); template.push("
"); FIRSTCLASS.layout.BlogFeed._rowReplyTemplateDomElement.innerHTML = template.join(""); } if (!FIRSTCLASS.layout.BlogFeed._microblogTemplateDomElement) { FIRSTCLASS.layout.BlogFeed._microblogTemplateDomElement = document.createElement("div"); template = []; template.push("
"); FIRSTCLASS.layout.BlogFeed._microblogTemplateDomElement.innerHTML = template.join(""); } if (config.listView) { this.listView = config.listView; } this._numComments = []; this._numUnread = []; this._dataSource = config.dataSource; this._theBlog = config.theBlog; this.elementWithToolbar = false; this._todayShown = false; this._clickedElement = null; this._selectedElement = null; this._selectedRow = null; this._blogURI = FIRSTCLASS.lang.ensureSlashUrl(FIRSTCLASS.util.User.getProfileUrlByCid(this._theBlog._userCID)); this.message = null; this.findRowElement = function(evt){ return that.listView.findRowElement(evt); }; var uri = this._blogURI; var idx = uri.indexOf(FIRSTCLASS.session.baseURL); if (idx >= 0 && uri.length - idx > FIRSTCLASS.session.baseURL.length) { this._permaLinkBase = uri.substring(0,idx+FIRSTCLASS.session.baseURL.length) + "#" + uri.substr(idx+FIRSTCLASS.session.baseURL.length); } else { this._permLinkBase = ""; } this._dataSource.addRowListener({ onThread: function (thread) { if (thread.length > 1) { YAHOO.util.Dom.setStyle(document.getElementById('hrRuler[' + thread[0].threadid + ']'),'display',''); } } }); this._desktopRow = FIRSTCLASS.util.BuddyList.isBuddy(this._theBlog._userCID); this._unread = 0; this.toolBarDomElement = document.createElement("div"); YAHOO.util.Dom.setStyle(this.toolBarDomElement,'padding-left','0px'); YAHOO.util.Dom.setStyle(this.toolBarDomElement.firstChild,'padding-left','0px'); this.createToolbar(); }; FIRSTCLASS.layout.BlogFeed.instances = 0; FIRSTCLASS.layout.BlogFeed._rowDocTemplateDomElement = null; FIRSTCLASS.layout.BlogFeed._rowReplyTemplateDomElement = null; FIRSTCLASS.layout.BlogFeed._microblogTemplateDomElement = null; FIRSTCLASS.layout.BlogFeed.prototype.onRender = function(evt,popupOverlay) { popupOverlay.innerHTML = ""; }; FIRSTCLASS.layout.BlogFeed.prototype.createToolbar = function() { var that = this; this.toolBarButtonCfg = { domElement:this.toolBarDomElement, buttons: [ { id: "fcBlogComment" + this.instance, label: FIRSTCLASS.locale.toolbars.feed.comment, fcid: 'comment' }, { id: "fcFeedQuote" + this.instance, label: FIRSTCLASS.locale.toolbars.feed.quote, fcid: 'quote', condition: function(row) { var sel = FIRSTCLASS.ui.getSelection(); return FIRSTCLASS.permissions.hasPriv(row.acl, FIRSTCLASS.permissions.ACL.SEND) && ((row.typedef.objtype == FIRSTCLASS.objTypes.odocument) || (row.typedef.objtype == FIRSTCLASS.objTypes.confitem)) && (sel.length > 0) && row.threadid != "0"; } }, { id: "fcBlogEdit" + this.instance, label: FIRSTCLASS.locale.toolbars.feed.edit, fcid: 'edit', condition: function(row) { return (row.creatorcid == FIRSTCLASS.session.user.cid) && (row.typedef.objtype==FIRSTCLASS.objTypes.odocument); } }, { id: "fcBlogDelete"+ this.instance, label: FIRSTCLASS.locale.toolbars.feed.del, fcid: 'fcdelete', condition: function(row) { 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: "fcBlogWatch" + this.instance, label: FIRSTCLASS.locale.toolbars.feed.watch, type: "unchecked", fcid: 'blogwatch', condition: function(row) { if ((row.threadid === "0") || (row.typedef.objtype != FIRSTCLASS.objTypes.odocument)) { return false; } if (row.watched) { return false; } var rv = true; if (FIRSTCLASS.session.desktop && FIRSTCLASS.session.desktop._dataSource) { rv = !FIRSTCLASS.session.desktop.isThreadBeingWatched(row.threadid); } return rv; } }, { id: "fcBlogUnWatch" + this.instance, label: FIRSTCLASS.locale.toolbars.feed.watch, type: "checked", fcid: 'unwatch', condition: function(row) { if ((row.threadid === "0") || (row.typedef.objtype != FIRSTCLASS.objTypes.odocument)) { return false; } if (row.watched) { return true; } var rv = false; if (FIRSTCLASS.session.desktop && FIRSTCLASS.session.desktop._dataSource) { rv = FIRSTCLASS.session.desktop.isThreadBeingWatched(row.threadid); } return rv; } }, { id: "fcBlogShare" + this.instance, label: FIRSTCLASS.locale.toolbars.documents.share, fcid: 'share', type: "popup", popup: { width: 320, height: 500, callbacks: { onRender: function(evt, el) { FIRSTCLASS.ui.sharePopup.showShareDialog(YAHOO.util.Event.getTarget(evt),el,that._selectedRow,that._dataSource,"blog"); }, onClose: function() { // that.hideShareDialog(); } } }, condition: function(row) { return row.threadid != "0"; } }, { id: "fcFeedPrint" + this.instance, label: FIRSTCLASS.locale.toolbars.feed.print, fcid: 'print' } ] }; this.toolBar = new FIRSTCLASS.ui.toolBar(this.toolBarButtonCfg); }; FIRSTCLASS.layout.BlogFeed.prototype.checkSelect = function() { this._selection = FIRSTCLASS.ui.getSelection(); this.toolBar.reconfigure(this._selectedRow); }; FIRSTCLASS.layout.BlogFeed.prototype.eventHandlers = { click: { /* title: function(el, that, fcevent) { if (that._config.headerClickFunc) { that._config.headerClickFunc(el.row); return true; } return false; }, */ less: function(el, that, fcevent, evt) { var row = el.row; row.bitemdata = row.itemdata; row.itemdata = false; var currTable = fcevent.target.parentNode.parentNode.parentNode.parentNode.parentNode; that._dataSource.notifyRowChanged(row, { status: row.status, itemdata: row.bitemdata }); if (row.typedef.objtype == FIRSTCLASS.objTypes.confitem) { that.onSelectionChange(evt, currTable.parentNode); } else { that.onSelectionChange(evt, currTable); } fcevent.target.innerHTML = FIRSTCLASS.locale.community.feed.more; }, more: function(el, that, fcevent, evt) { var row = el.row; var currTable = fcevent.target.parentNode.parentNode.parentNode.parentNode.parentNode; if (row.bitemdata) { row.itemdata = row.bitemdata; row.bitemdata = false; that._dataSource.notifyRowChanged(row, { status: row.status, itemdata: false }); } else { that._dataSource.fetchItem(row); } if (row.typedef.objtype == FIRSTCLASS.objTypes.confitem) { that.onSelectionChange(evt, currTable.parentNode); } else { that.onSelectionChange(evt, currTable); } fcevent.target.innerHTML = FIRSTCLASS.locale.community.feed.loading; }, print: function(el, that, fcevent) { if (el.row.threadid == "0") { return false; } window.open(FIRSTCLASS.session._activeObject + el.row.uri + "?Templates=Print"); }, edit: function(el, that, fcevent) { if (FIRSTCLASS.session.canNavigateAway()) { that.clearEmailMsg(); that.clearBlogEdit(); var tbcontainer = FIRSTCLASS.ui.Dom.getChildByClassName("fclvrowtoolbar", that._selectedElement); if (tbcontainer) { YAHOO.util.Dom.addClass(tbcontainer, "fcHidden"); } that.editBlogPost(el, that); } }, comment: function(el, that, fcevent) { if (FIRSTCLASS.session.canNavigateAway()) { that.clearBlogEdit(); that.clearEmailMsg(); var tbcontainer = FIRSTCLASS.ui.Dom.getChildByClassName("fclvrowtoolbar", that._selectedElement); if (tbcontainer) { YAHOO.util.Dom.addClass(tbcontainer, "fcHidden"); } that.replyToBlogPost(el, that, false); } }, fcdelete: function(el, that, fcevent) { that.deleteBlogPost(el.row, el.el); }, blogwatch: function(el, that, fcevent) { that._dataSource.watchItem(el.row); el.row.watched = true; that.toolBar.reconfigure(el.row); }, unwatch: function(el, that, fcevent) { var node = el.el.firstChild.childNodes[1].firstChild.firstChild.firstChild.firstChild, text; if (YAHOO.env.ua.ie) { text = node.innerText; } else { text = node.textContent; } node.innerHTML = text; FIRSTCLASS.session.desktop.deleteWatch(el.row); el.row.watched = false; that.toolBar.reconfigure(el.row); }, 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); }, reset: function(el, that, fcevent) { that._singleThreadView = false; that._dataSource._config.fetchThreadID = false; that._dataSource._config.watchForNew = true; that._dataSource.fetchRows(); that.listView.updateConfigParams({ fillOnScroll: true, autoLoad: true, watchForNew: true }); that.listView.reLoadFromDataSource(); that.listView.activate(); that.listView.clearPadText(); that.createToolbar(); FIRSTCLASS.session.addHistoryEntry({ "uri": that._dataSource._config.containerBaseUrl, "app": that._theBlog._theProfile, activate: function() { that._theBlog._theProfile.activate(); } }); } }, mousedown: { quote: function(el, that, fcevent) { that.replyToBlogPost(el, that, true); } }, /* feedRow: function(el, that, fcevent) { if (el.row.uri == that._selectedRow.uri) { that.checkSelect(); } } }, */ mouseup: { feedrow: function(el, that, fcevent) { if (that._selectedRow && el.row.uri == that._selectedRow.uri) { that.checkSelect(); } } } }; FIRSTCLASS.layout.BlogFeed.prototype.handleEvent = function(evt, fcevent) { var handlers = this.eventHandlers[evt.type]; if (handlers) { var handler = handlers[fcevent.fcid]; if (handler) { var el = (fcevent.fcid=='reset') ? null : this.findRowElement(evt); var rv = handler(el, this, fcevent,evt); if (typeof rv == "undefined") { rv = true; } return rv; } } }; /** * the row draw function * * @Method BlofFeed.createRow * @param {Object} row (required) the row to draw * @static */ FIRSTCLASS.layout.BlogFeed.prototype.createRow = function(row) { var table; var that = this; if (typeof this._numComments[row.threadid] == 'undefined') { this._numComments[row.threadid] = []; this._numUnread[row.threadid] = 0; } if (row.lformid == 21008 || row.icon.id == 9626) { table = FIRSTCLASS.layout.BlogFeed._microblogTemplateDomElement.firstChild.cloneNode(true); } else if (row.typedef.objtype == FIRSTCLASS.objTypes.confitem) { table = FIRSTCLASS.layout.BlogFeed._rowReplyTemplateDomElement.firstChild.cloneNode(true); var foundIt = false; for (var item in this._numComments[row.threadid]) { if (item == row.uri) { foundIt = true; break; } } if (!foundIt) { this._numComments[row.threadid][this._numComments[row.threadid].length] = row.uri; if (row.status.unread) { this._numUnread[row.threadid] = this._numUnread[row.threadid] + 1; } } } else { table = FIRSTCLASS.layout.BlogFeed._rowDocTemplateDomElement.firstChild.cloneNode(true); YAHOO.util.Event.addListener(table, 'click', function(evt) { that.onSelectionChange(evt,this); } ); } return table; }; FIRSTCLASS.layout.BlogFeed.prototype.findBlogPost = function (currRow) { var parentDiv = currRow; while (parentDiv !== null) { if (YAHOO.util.Dom.hasClass(parentDiv, 'fcListViewThread')) { break; } else { parentDiv = parentDiv.parentNode; } } return parentDiv; }; FIRSTCLASS.layout.BlogFeed.prototype.editBlogPost = function (el,tableRow) { if (el) { var editElem = document.createElement('div'); tableRow._selectedElement.appendChild(editElem); this._theBlog.editPage(el.row,tableRow._selectedElement,editElem); } }; FIRSTCLASS.layout.BlogFeed.prototype.deleteBlogPost = function (theRow,theElement) { var theMsg = (theRow.typedef.objtype==FIRSTCLASS.objTypes.odocument) ? FIRSTCLASS.locale.blog.deleteBlog : FIRSTCLASS.locale.blog.deleteComment; if (!confirm(theMsg)) { return; } var itemURL = FIRSTCLASS.lang.ensureSlashUrl(this._dataSource.getItemUrl(theRow)); var questionMark = itemURL.indexOf('?',0); if (questionMark >= 0) { itemURL = itemURL.substr(0,questionMark+1); } if (theRow.typedef.objtype==FIRSTCLASS.objTypes.odocument) { this._dataSource.deleteThread(theRow); theElement = document.getElementById('fcListView' + this.listView._ListViewID + 'Thread'+ theRow.threadid); if (theElement !== null) { theElement.parentNode.removeChild(theElement); } } else { FIRSTCLASS.util.net.asyncRequest('GET',itemURL+"Delete=1", null); theElement.parentNode.removeChild(theElement); } }; FIRSTCLASS.layout.BlogFeed.prototype.emailBlogPost = function (row,rowID) { var that = this; var theBody = (row.itemdata && row.itemdata.expandedBody) ? row.itemdata.expandedBody : row.expandedPreview; var sendLinkMsg = document.createElement("div"); sendLinkMsg.Id = 'fc_BlogFeed_linkMsg'; // this._emailBlogURL = FIRSTCLASS.lang.ensureSlashUrl(this._dataSource.getItemUrl(row)); this._overlay = new YAHOO.widget.Overlay(sendLinkMsg,{visible:true, height:500, width:700}); var msgCfg = { baseURL: FIRSTCLASS.session.baseURL + "/Open-User/CID" + FIRSTCLASS.session.user.cid + "/Mailbox/", callback: { onCancel: function () { that.clearEmailMsg(); }, onSave: function () { that.clearEmailMsg(); }, onLoaded: function () {that.setEmailFields(); } }, // callback: this, op: "__Send", element: sendLinkMsg, objType: FIRSTCLASS.objTypes.message, body: "HTML", formID: 21005, formElId: "fcDocForm", bodyType: "HTML", sendTo: null, showAddr: true, initHeight: 500, initWidth: 700, params: "InitialText=[Add your comments here]

" + theBody }; this._overlay.center(); this._overlay.render(rowID); this.message = new FIRSTCLASS.util.Message(msgCfg); }; FIRSTCLASS.layout.BlogFeed.prototype.hideComments = function (evt,clickElement) { var el = this.findRowElement(evt); if (el) { // this.onSelectionChange(evt,clickElement); YAHOO.util.Event.stopPropagation(evt); var allComments = document.getElementById('ThreadBody' + el.row.threadid); YAHOO.util.Dom.setStyle(clickElement,'display','none'); YAHOO.util.Dom.setStyle(clickElement.nextSibling,'display',''); YAHOO.util.Dom.setStyle(clickElement.nextSibling.nextSibling,'display',''); YAHOO.util.Dom.setStyle(clickElement.nextSibling.nextSibling.nextSibling,'display',''); YAHOO.util.Dom.setStyle(allComments,'display','none'); if (this.message !== null) { this.message.onCancel(); this.message.destroy(); this.message = null; } } }; FIRSTCLASS.layout.BlogFeed.prototype.showBlogComments = function (evt,clickElement) { // DO NOT STOP PROPOGATION YAHOO.util.Event.stopPropagation(evt); var el = this.findRowElement(evt); if (el) { // this.onSelectionChange(evt,clickElement); this.showThreadComments(el.row.threadid,clickElement); } }; FIRSTCLASS.layout.BlogFeed.prototype.showThreadComments = function (threadID,clickElement) { if ((typeof this._numComments[threadID] != 'undefined') && (this._numComments[threadID].length > 0)) { var allComments = document.getElementById('ThreadBody' + threadID); // move back until we get first section var firstTD = clickElement; while ((firstTD !== null) && (firstTD.className != 'fcBlogCommentInfo')) { firstTD = firstTD.previousSibling; } if (firstTD !== null) { YAHOO.util.Dom.setStyle(firstTD,'display','none'); YAHOO.util.Dom.setStyle(firstTD.nextSibling,'display','none'); YAHOO.util.Dom.setStyle(firstTD.nextSibling.nextSibling,'display','none'); // YAHOO.util.Dom.setStyle(firstTD.previousSibling,'display',''); YAHOO.util.Dom.setStyle(allComments,'display','inline'); } } }; FIRSTCLASS.layout.BlogFeed.prototype.replyToBlogPost = function (el,theBlog,useQuotes) { if (this.message === null) { if (el) { this._blogSpot = FIRSTCLASS.ui.Dom.getChildByClassName('fcBlogLeaveComment',el.el); YAHOO.util.Dom.removeClass(this._blogSpot, "fcHidden"); var msgCfg = { baseURL: FIRSTCLASS.lang.ensureSlashUrl(this._dataSource.getItemUrl(el.row)), callback: this, op: FIRSTCLASS.opCodes.Reply, params: "Quote=0&InitialText=", element: this._blogSpot, objType: FIRSTCLASS.objTypes.message, formID: 21003, formElId: "fcDocForm", bodyType: "HTML", initHeight: "170px", autoHeight: true, quoteText: null, sendTo: null, showAddr: false, tbType: "reply" }; if (useQuotes) { if (this._selection) { msgCfg.quoteText = this._selection; } msgCfg.quoteAuth = el.row.col8082 ? el.row.col8082 : el.row.name; } this.message = new FIRSTCLASS.util.Message(msgCfg); } } }; FIRSTCLASS.layout.BlogFeed.prototype.clearBlogEdit = function() { if (this._theBlog._editor) { this._theBlog._editor.onCancel(); } }; FIRSTCLASS.layout.BlogFeed.prototype.clearEmailMsg = function() { if (typeof this._overlay != 'undefined') { this._overlay.hide(); this._overlay = null; } if (this.message !== null) { this.message.destroy(); this.message = null; } }; FIRSTCLASS.layout.BlogFeed.prototype.setEmailFields = function() { var emailDomElem = document.getElementById('Subject'); emailDomElem.value = "Thought you might be interested in this blog post"; }; FIRSTCLASS.layout.BlogFeed.prototype.onLoaded = function() { var cancelBtn = $('fcDocFormCancel'); if (cancelBtn !== null) { YAHOO.util.Dom.setStyle(cancelBtn, "display", "inline"); } }; FIRSTCLASS.layout.BlogFeed.prototype.onCancel = function() { this.message.destroy(); this.message = null; if (typeof this._blogSpot != 'undefined') { if (this._blogSpot !== null) { YAHOO.util.Dom.addClass(this._blogSpot, "fcHidden"); this._blogSpot.innerHTML = ""; this._blogSpot = null; } } var tbcontainer = FIRSTCLASS.ui.Dom.getChildByClassName("fclvrowtoolbar",this._selectedElement); if (tbcontainer) { YAHOO.util.Dom.removeClass(tbcontainer, "fcHidden"); } }; FIRSTCLASS.layout.BlogFeed.prototype.onSave = function() { this.message.destroy(); this.message = null; this._dataSource.fetchNewRows(); if (typeof this._blogSpot != 'undefined') { if (this._blogSpot !== null) { YAHOO.util.Dom.addClass(this._blogSpot, "fcHidden"); this._blogSpot.innerHTML = ""; this._blogSpot = null; } } }; FIRSTCLASS.layout.BlogFeed.prototype.onFail = function(obj) { this.message.destroy(); this.message = null; if (typeof this._blogSpot != 'undefined') { if (this._blogSpot !== null) { this._blogSpot.innerHTML = ""; this._blogSpot = null; } } if (obj && obj.error) { FIRSTCLASS.ui.navBar.updateShoutBox(FIRSTCLASS.locale.errors.getErrorString(obj.error)); } }; FIRSTCLASS.layout.BlogFeed.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 || row.status.unread != oldRow.status.unread) { if (row.status.unread) { this._unread += 1; } else { this._unread -= 1; } if (this._unread < 0) { this._unread = 0; } if (this._desktopRow) { this._desktopRow.status.unread = this._unread; FIRSTCLASS.apps.Desktop.instance._dataSource.notifyRowChanged(this._desktopRow); } } if (oldRow && oldRow.onlyunread) { YAHOO.util.Dom.removeClass(element.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode, "unread"); } if (row.lformid == 21008 || row.icon.id == 9626) { this.updateMicroBlogPost(row,element, oldRow); } else if (row.typedef.objtype == FIRSTCLASS.objTypes.confitem) { this.updateReplyPost(row,element,oldRow); } else { this.updateBlogPost(row,element,oldRow); } }; FIRSTCLASS.layout.BlogFeed.prototype.updateMicroBlogPost = function(row,element,oldRow) { var body = FIRSTCLASS.ui.Dom.getChildByClassName("entry-content", element); var timestamp = FIRSTCLASS.ui.Dom.getChildByClassName("timestamp", element); body.innerHTML = row.expandedPreview; if (row.icon.id == 9626) { YAHOO.util.Dom.addClass(element, 'music-update'); } else { YAHOO.util.Dom.addClass(element, 'status-update'); } timestamp.innerHTML = FIRSTCLASS.util.Date.getFriendlyDateTimeString(row.lastmods); //
}; FIRSTCLASS.layout.BlogFeed.prototype.updateReplyPost = function(row,element,oldRow) { if ((oldRow !== null) && (typeof oldRow.status != 'undefined') && (oldRow.status.unread == 1)) { return; } var singleDomElement; var table = element.firstChild; singleDomElement = table.childNodes[0].childNodes[1].childNodes[3]; /* singleDomElement = FIRSTCLASS.ui.Dom.getChildByClassName("fcBlogBodyComment", table);*/ /* var moreitem = FIRSTCLASS.ui.Dom.getChildByClassName("fcMore", table);*/ var moreitem = table.childNodes[0].childNodes[1].childNodes[4]; if (moreitem) { YAHOO.util.Dom.setStyle(moreitem, 'padding-left', '0px'); } if (moreitem) { YAHOO.util.Dom.setStyle(moreitem, 'padding-left', '0px'); if (row.itemdata || !row.status.complete || row.status.attachments) { 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; } moreitem.innerHTML = ""+str+""; } } if (singleDomElement) { if (row.itemdata && row.itemdata.expandedBody) { singleDomElement.innerHTML = row.itemdata.expandedBody; YAHOO.util.Dom.addClass(element, 'bodyexpanded'); } else if (row.expandedPreview) { singleDomElement.innerHTML = row.expandedPreview; } else { singleDomElement.innerHTML = ""; } if (row.status.complete) { YAHOO.util.Dom.setStyle(moreitem, 'display', 'none'); moreitem.innerHTML = ""; } } /* hack to fix the height css on embedded images */ var imgs = singleDomElement.getElementsByTagName("IMG"); for (var i = 0; i < imgs.length; i++) { var img = imgs[i]; YAHOO.util.Dom.setStyle(img, "height", "auto"); } /* end hack */ this.updateNumComments(row.threadid); /*singleDomElement = FIRSTCLASS.ui.Dom.getChildByClassName("fcBlogReplyPic", table);*/ singleDomElement = table.childNodes[0].childNodes[0].childNodes[0]; if (singleDomElement) { if (!row.status.unread) { YAHOO.util.Dom.setStyle(singleDomElement,'width','20px'); YAHOO.util.Dom.setStyle(singleDomElement,'height','27px'); } FIRSTCLASS.util.User.setSmallProfPicUrlByCid(singleDomElement,row.creatorcid,false); singleDomElement.setAttribute('fcattrs', row.col8010); } singleDomElement = table.childNodes[0].childNodes[1].childNodes[0]; /*singleDomElement = FIRSTCLASS.ui.Dom.getChildByClassName("fcMessageSender", table);*/ if (singleDomElement) { singleDomElement.innerHTML = row.name.toUpperCase(); var theUID = (typeof row.creatorcid == "string" && row.creatorcid.indexOf("CID") === 0) ? parseInt(row.creatorcid.substr(3),10) : row.creatorcid; if ("CID"+theUID != this._theBlog._userCID) { singleDomElement.setAttribute('fcid', 'user'); singleDomElement.setAttribute('fcattrs', row.col8010); singleDomElement.setAttribute('uid', theUID); } } singleDomElement = FIRSTCLASS.ui.Dom.getChildByClassName("fcMessageDate", table); if (singleDomElement) { singleDomElement.innerHTML = FIRSTCLASS.util.Date.getFriendlyDateTimeString(row.lastmods); } }; FIRSTCLASS.layout.BlogFeed.prototype.reduceNumComments = function(theThreadID) { this._numUnread[theThreadID] = this._numUnread[theThreadID] - 1; if (this._numUnread[theThreadID] === 0) { YAHOO.util.Dom.removeClass(this._numComments[theThreadID].commentDomElem.nextSibling,'fcFlag'); FIRSTCLASS.ui.Dom.setInnerHTML(this._numComments[theThreadID].commentDomElem.nextSibling,""); FIRSTCLASS.ui.Dom.setInnerHTML(this._numComments[theThreadID].commentDomElem.nextSibling.nextSibling,""); } }; FIRSTCLASS.layout.BlogFeed.prototype.updateNumComments = function(theThreadID) { var that = this; var commentInfo = this._numComments[theThreadID].commentDomElem; if (commentInfo) { var unreadComments = commentInfo.nextSibling; var numComments = this._numComments[theThreadID].length; if (numComments > 0) { var commentText; YAHOO.util.Event.purgeElement(commentInfo, true); YAHOO.util.Event.addListener(commentInfo, 'click', function(evt) { that.showBlogComments(evt,this); } ); if (numComments == 1) { commentText = "1 comment"; } else { commentText = numComments + " comments"; } if (this._numUnread[theThreadID] > 0) { FIRSTCLASS.ui.Dom.setInnerHTML(commentInfo,commentText + " | "); YAHOO.util.Dom.addClass(unreadComments,'fcFlag'); FIRSTCLASS.ui.Dom.setInnerHTML(unreadComments,this._numUnread[theThreadID]+""); FIRSTCLASS.ui.Dom.setInnerHTML(unreadComments.nextSibling," unread"); YAHOO.util.Event.purgeElement(unreadComments, true); // YAHOO.util.Event.addListener(unreadComments, 'click', function(evt) { that.showBlogComments(evt,this); } ); YAHOO.util.Event.purgeElement(unreadComments.nextSibling, true); YAHOO.util.Event.addListener(unreadComments.nextSibling, 'click', function(evt) { that.showBlogComments(evt,this); } ); if (YAHOO.util.Dom.getStyle(unreadComments.previousSibling.previousSibling,'display') == 'none') { this.showThreadComments(theThreadID,commentInfo); } } else { FIRSTCLASS.ui.Dom.setInnerHTML(commentInfo,commentText); YAHOO.util.Dom.setStyle(unreadComments,'display','none'); } } } }; FIRSTCLASS.layout.BlogFeed.prototype.updateBlogPost = function(row,element,oldRow) { if ((oldRow !== null) && (typeof oldRow.status != 'undefined') && (oldRow.status.unread == 1)) { return; } var table = element; //var theRuler = FIRSTCLASS.ui.Dom.getChildByIdName('hrRuler',table); var theRuler = table.childNodes[0].childNodes[6].childNodes[0].childNodes[0]; if (theRuler) { theRuler.id = 'hrRuler[' + row.threadid + ']'; } element.id = this.listView._generateDivID(row); var clickDomElem = FIRSTCLASS.ui.Dom.getChildByClassName("fcBlogCommentInfo", table); if (!clickDomElem) { // replacing a thread header, we'll have to rebuild the row var blogPostTable = FIRSTCLASS.layout.BlogFeed._rowDocTemplateDomElement.firstChild.cloneNode(true); FIRSTCLASS.ui.Dom.clearElementChildren(element); FIRSTCLASS.ui.Dom.reparentNode(blogPostTable.firstChild, element); table = element.firstChild; clickDomElem = FIRSTCLASS.ui.Dom.getChildByClassName("fcBlogCommentInfo", table); } var toolBarDomElement = table.childNodes[0].childNodes[5].childNodes[0]; var titleDomElement = table.childNodes[0].childNodes[1].childNodes[0].childNodes[0].childNodes[0].childNodes[0]; var dateDomElement = table.childNodes[0].childNodes[0].childNodes[0].childNodes[0]; var nameDomElement = table.childNodes[0].childNodes[4].childNodes[0].childNodes[0].childNodes[0].childNodes[0].childNodes[0].childNodes[1]; var timeDomElement = table.childNodes[0].childNodes[4].childNodes[0].childNodes[0].childNodes[0].childNodes[0].childNodes[0].childNodes[2]; var bodyText = table.childNodes[0].childNodes[2].childNodes[0].childNodes[0]; var moreitem = table.childNodes[0].childNodes[2].childNodes[0].childNodes[1]; var theTags = table.childNodes[0].childNodes[3].childNodes[0].childNodes[0]; var realTitle; this._numComments[row.threadid].commentDomElem = clickDomElem; YAHOO.util.Dom.addClass(toolBarDomElement,"fcMessageToolBar"); this.updateNumComments(row.threadid); if (row.itemdata && row.itemdata.title) { realTitle = FIRSTCLASS.lang.mlesc(row.itemdata.title); } else { realTitle = FIRSTCLASS.lang.mlesc(row.col14); } if ((typeof row.watched != 'undefined') && row.watched) { FIRSTCLASS.ui.Dom.setInnerHTML(titleDomElement,""+realTitle); } else if (FIRSTCLASS.session.desktop && FIRSTCLASS.session.desktop._dataSource &&FIRSTCLASS.session.desktop.isThreadBeingWatched(row.threadid)) { FIRSTCLASS.ui.Dom.setInnerHTML(titleDomElement,""+realTitle); } else { FIRSTCLASS.ui.Dom.setInnerHTML(titleDomElement,realTitle); } titleDomElement.parentNode.setAttribute('title', 'Subject:' + titleDomElement.innerHTML); var theRowDate = new Date(); theRowDate.setTime(row.lastmods*1000); var now = new Date(); if ((now.getFullYear() == theRowDate.getFullYear()) && (now.getMonth() == theRowDate.getMonth()) && (now.getDate() == theRowDate.getDate())) { if (!this._todayShown) { this._todayShown = true; FIRSTCLASS.ui.Dom.setInnerHTML(dateDomElement,FIRSTCLASS.locale.blog.today); } } else { FIRSTCLASS.ui.Dom.setInnerHTML(dateDomElement, theRowDate.getDate() + " " + FIRSTCLASS.util.Date.getMonthString(theRowDate) + " " + theRowDate.getFullYear()); } if (nameDomElement) { if (row.col8082) { FIRSTCLASS.ui.Dom.setInnerHTML(nameDomElement, row.col8082.toUpperCase() + " "); } else { if (typeof row.col8010 != 'undefined') { FIRSTCLASS.ui.Dom.setInnerHTML(nameDomElement, row.col8010.toUpperCase() + " "); } else { FIRSTCLASS.ui.Dom.setInnerHTML(nameDomElement, FIRSTCLASS.locale.blog.noauthor + " "); } } } if (timeDomElement) { var whenPosted = FIRSTCLASS.util.Date.getFriendlyTimeString(row.lastmods); if (isNaN(whenPosted.charAt(0))) { FIRSTCLASS.ui.Dom.setInnerHTML(timeDomElement, whenPosted); } else { FIRSTCLASS.ui.Dom.setInnerHTML(timeDomElement, " AT " + whenPosted); } } if (moreitem) { YAHOO.util.Dom.setStyle(moreitem, 'padding-left', '0px'); if (row.itemdata || !row.status.complete || row.status.attachments) { 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; } moreitem.innerHTML = ""+str+""; } } if (bodyText) { if (row.itemdata && row.itemdata.expandedBody) { if (bodyText.innerHTML != row.itemdata.expandedBody) { FIRSTCLASS.ui.Dom.setInnerHTML(bodyText, row.itemdata.expandedBody); YAHOO.util.Dom.addClass(element, 'bodyexpanded'); } } else if (row.expandedPreview) { if (bodyText.innerHTML != row.expandedPreview) { FIRSTCLASS.ui.Dom.setInnerHTML(bodyText, row.expandedPreview); } } else { FIRSTCLASS.ui.Dom.setInnerHTML(bodyText,""); } if (row.status.complete) { YAHOO.util.Dom.setStyle(moreitem, 'display', 'none'); moreitem.innerHTML = ""; } } /* hack to fix the height css on embedded images */ var imgs = bodyText.getElementsByTagName("IMG"); for (var i = 0; i < imgs.length; i++) { var img = imgs[i]; YAHOO.util.Dom.setStyle(img, "height", "auto"); } /* end hack */ if (row.tags.length > 0) { if (theTags) { theTags.innerHTML = "" + FIRSTCLASS.locale.community.feed.tags + "" + FIRSTCLASS.ui.generateCloud(FIRSTCLASS.ui.parseServerTags(row.tags)) + ""; // FIRSTCLASS.ui.Dom.setInnerHTML(theTags,FIRSTCLASS.locale.blog.tags + ": " + row.tags + "
"); YAHOO.util.Dom.setStyle(theTags,"display",""); } } }; FIRSTCLASS.layout.BlogFeed.prototype.setForm = function(elem, node, theBaseURL) { var child = FIRSTCLASS.ui.Dom.getChildByClassName("fclvrowformdoc", node); if (node.formElement) { // YAHOO.util.Event.purgeElement(node.formElement, true); child.removeChild(node.formElement); } if (node.message) { delete node.message; } node.formElement = elem; child.appendChild(elem); var msgCfg = { callback: this, element: elem, objType: FIRSTCLASS.objTypes.odocument, body: "HTML", formID: 21003, formElId: "fcDocForm", bodyType: "HTML", quoteText: null, sendTo: null, baseURL: theBaseURL }; node.message = new FIRSTCLASS.util.Message(msgCfg); }; FIRSTCLASS.layout.BlogFeed.prototype.clearForm = function(node) { if (node.formElement) { var child = FIRSTCLASS.ui.Dom.getChildByClassName("fclvrowformdoc", node); child.innerHTML = ""; delete node.formElement; node.formElement = null; } if (node.message) { delete node.message; } }; FIRSTCLASS.layout.BlogFeed.prototype.generateUniqueId = function(row) { return row.messageid; }; FIRSTCLASS.layout.BlogFeed.prototype.setListView = function(listView) { this.listView = listView; }; FIRSTCLASS.layout.BlogFeed.prototype.onSelectionChange = function(evt,clickElem) { var tbcontainer = null; if (clickElem && (this._clickedElement !== clickElem)) { FIRSTCLASS.ui.embeds.clearEmbed(); var el = this.findRowElement(evt); if (el) { var theID; this._selectedRow = el.row; if (el.row.typedef.objtype == FIRSTCLASS.objTypes.confitem) { theID = "comment[" + el.row.uri + "]"; } else { theID = "blog[" + el.row.uri + "]"; } var theParent = clickElem.parentNode; while (theParent !== null) { if (theParent.id == theID) { break; } theParent = theParent.parentNode; } if (theParent) { YAHOO.util.Dom.addClass(theParent.parentNode,"fcProfileSelected"); YAHOO.util.Dom.addClass(theParent.parentNode,"selected"); var theBody = FIRSTCLASS.ui.Dom.getChildByClassName('fcBlogBodyComment',theParent.parentNode); if (theBody) { YAHOO.util.Dom.setStyle(theBody,'height','100%'); YAHOO.util.Dom.setStyle(theBody,'overflow','auto'); } } if (el.row.status.unread) { if (el.row.typedef.objtype != FIRSTCLASS.objTypes.odocument) { this.reduceNumComments(el.row.threadid); } if (theParent) { YAHOO.util.Dom.addClass(theParent.parentNode,"recentlyread"); } this._dataSource.toggleUnRead(el.row, 0); this._theBlog._unreadItem[el.row.uri] = null; } // if (el.row.typedef.objtype == FIRSTCLASS.objTypes.odocument) { tbcontainer = FIRSTCLASS.ui.Dom.getChildByClassName("fclvrowtoolbar",clickElem); if (tbcontainer) { tbcontainer.innerHTML = ""; YAHOO.util.Dom.removeClass(tbcontainer, "fcHidden"); FIRSTCLASS.ui.Dom.reparentNode(this.toolBarDomElement, tbcontainer); this.toolBar.reconfigure(el.row); } // } if (this._selectedElement) { YAHOO.util.Dom.removeClass(this._selectedElement,"fcProfileSelected"); YAHOO.util.Dom.removeClass(this._selectedElement,"selected"); tbcontainer = FIRSTCLASS.ui.Dom.getChildByClassName("fclvrowtoolbar",this._selectedElement); if (tbcontainer) { YAHOO.util.Dom.addClass(tbcontainer, "fcHidden"); tbcontainer.innerHTML = "
"; } } this._selectedElement = theParent.parentNode; this._clickedElement = clickElem; } } }; YAHOO.register("fcBlogFeed", FIRSTCLASS.layout.BlogFeed, {version: "0.0.1", build: "1"});