/** * Class Description * @namespace FIRSTCLASS.apps * @module Community * @requires * @optional * @title Community base Application */ /** * Constructor definition * @class Community * @constructor * @param {Object} config (required) the configuration object * @param {string|HTMLElement} config.div (required) the div to load into * @param {string} config.baseUrl (required) the container base url */ FIRSTCLASS.apps.Community = function(config) { /** * Private member variables * * Private variables are identified by the convention of naming them with a leading underscore. * i.e. this._privateVariable */ this._instanceCounter = FIRSTCLASS.apps.Community.instance++; if (config.logTime) { config.logTime("Community App Init"); } this._subApps = [ /*{label:"Feed", app:"fcCommunity", loaded:true, instance: this},*/ {label:FIRSTCLASS.locale.community.feed.lbl, app:"fcDiscussion", loaded:true, contentPane: true, tabName:"Feed"}, {label:FIRSTCLASS.locale.community.docs.lbl, app:"fcDocuments", loaded:false, contentPane: false, tabName:"Documents"}, {label:FIRSTCLASS.locale.community.wiki.lbl, app:"fcWiki", loaded:false, contentPane: false, tabName:"Wiki"} /*,{label:"Calendar", app:"fcCalendar", loaded:false}, {label:"Tasks", app:"fcTasks", loaded:false}*/ ]; var that = this; this._baseURL = ""; this._config = null; this._dataSource = null; this._tabView = null; this._tabs = {}; this._parentDiv = config.parentDiv; this._title = config.params.title; if (config.params.unread) { this._unread = config.params.unread; } else { this._unread = 0; } this._itemurl = config.params.itemurl; FIRSTCLASS.ui.navBar.setProfilePicture(config.params.icon, false, "about"); this._iconuri = config.params.icon; FIRSTCLASS.ui.navBar.setProfileUnread(this._unread); var that = this; this._config = config; if (typeof this._config.div == "string") { this._domElem = document.getElementById(this._config.divId); } else { this._domElem = this._config.div; } this._tabView = new YAHOO.widget.TabView(); for (var i = 0; i < this._subApps.length; i++) { var tab = this._subApps[i]; var act = ((i===0)?true:false); this._tabs[tab.tabName] = new YAHOO.widget.Tab({label: tab.label, active:act}); this._tabView.addTab(this._tabs[tab.tabName]); } this._tabView.addListener('activeTabChange', function(evt) { var oldTab = evt.prevValue.get("label"); var newTab = evt.newValue.get("label"); var oldTabDomElem = evt.prevValue.get("contentEl"); var newTabDomElem = evt.newValue.get("contentEl"); var newTabID = ""; for(var i = 0; i < that._subApps.length; i++) { if (that._subApps[i].label == oldTab) { if (that._subApps[i].instance) { that._subApps[i].instance.deactivate(true); if (that._subApps[i].domContents) { delete that._subApps[i].domContents; } that._subApps[i].domContents = FIRSTCLASS.ui.Dom.clearElementChildren(oldTabDomElem); } } if (that._subApps[i].label == newTab) { if (that._subApps[i].instance && that._subApps[i].domContents) { var domElem = evt.newValue.get("contentEl"); FIRSTCLASS.ui.Dom.replaceContents(newTabDomElem, that._subApps[i].domContents); delete that._subApps[i].domContents; } newTabID = that._subApps[i].tabName; } } that.loadApplication(newTabID, true, false, that._showoncomplete); that._showoncomplete = false; //that.resizeEvent(); }); this._tabView.addListener('beforeActiveTabChange', function(evt) { var oldTab = evt.prevValue.get("label"); var newTab = evt.newValue.get("label"); for(var i = 0; i < that._subApps.length; i++) { if (that._subApps[i].label == oldTab && that._subApps[i].instance && that._subApps[i].instance.isSafeToNavigate && !that._subApps[i].instance.isSafeToNavigate()) { var answer = confirm(FIRSTCLASS.locale.desktop.navaway.prefix + "\n\n" + FIRSTCLASS.locale.desktop.navaway.editing + "\n\n" + FIRSTCLASS.locale.desktop.navaway.suffix); return answer; } } }); var fragments = FIRSTCLASS.lang.removeSlashUrl(this._config.baseUrl).split("/"); var query = FIRSTCLASS.apps.Desktop.instance._dataSource.query("uri", fragments[fragments.length-1], true); if (query.length) { this._desktopRow = query[0][1]; } var dsconfig = { containerBaseUrl: this._config.baseUrl, autoLoad: false, watchForNew: true, messagebodies: false, nosymbiomainfetch: true, sortFirstFetch: false, serversort: "&Table=-3_9", fetchThreads: true, initialRequestGranularity: 5, requestGranularity: 10 }; if (this._config.logTime) { dsconfig.logTime = this._config.logTime; } this._dataSource = new FIRSTCLASS.util.DataSource(dsconfig); this._dataSource.addRowListener({ fillunread: 0, firstrow: 0, nrows: 0, onRow:function(row, dataSource) { that._config.onLoaded(); if (row.status.unread) { this.fillunread += 1; } if (!this.firstrow) { if (that._config.logTime) { that._config.logTime("Community App onRow Called on first row"); } this.firstrow = 1; } if (row.itemdata && that._config.logTime) { that._config.logTime("Community App onRow Called on row with body"); } this.nrows++; }, onFillCompleted:function(row, dataSource) { that._config.onLoaded(); //that._listView.updatePadText(FIRSTCLASS.locale.community.nomore); }, onRowChanged:function(row, dataSource, oldrow) { if (!oldrow || row.status.unread != oldrow.status.unread) { if (row.status.unread) { that._unread += 1; } else { that._unread -= 1; } if (that._unread < 0) { that._unread = 0; } FIRSTCLASS.ui.navBar.setProfileUnread(that._unread); that._unreadModified = true; if (that._desktopRow) { that._desktopRow.status.unread = that._unread; FIRSTCLASS.apps.Desktop.instance._dataSource.notifyRowChanged(that._desktopRow); } } }, fillFinished: function(isNewDelivery) { try { if (typeof soundManager != "undefined" && isNewDelivery) { soundManager.play("conference1"); } } catch (e) { } if (isNewDelivery) { that._unread += this.fillunread; FIRSTCLASS.ui.navBar.setProfileUnread(that._unread); that._unreadModified = true; } if (that._config.logTime) { that._config.logTime("Community App fillFinished Called, nrows received: " + this.nrows); this.firstrow = 0; } this.fillunread = 0; } }); this._dataSource.addDataListener({ onHeaderData:function(data, contents) { switch (data) { case "name": if (!that._title) { FIRSTCLASS.ui.setDocumentTitle(contents); that._title = contents; var title = that._title; FIRSTCLASS.ui.navBar.setTitle(FIRSTCLASS.lang.mlesc(title)); } break; case "objid": that._objid = contents; break; case "acl": if (FIRSTCLASS.permissions.hasPriv(contents, FIRSTCLASS.permissions.ACL.MODERATOR) == FIRSTCLASS.permissions.ACL.MODERATOR) { that._membersAppAction = true;//function(evt) { that.loadMembersApp(); }; FIRSTCLASS.ui.rightSideBar.updateBoxAction(FIRSTCLASS.locale.community.members.lbl, false, false, 'members'); that._aclConfigured = true; that._config.acl = contents; } var subheader = document.createElement("div"); YAHOO.util.Dom.setStyle(subheader, 'text-align', 'right'); if (FIRSTCLASS.permissions.hasPriv(contents, FIRSTCLASS.permissions.ACL.EDITWINFO) == FIRSTCLASS.permissions.ACL.EDITWINFO && FIRSTCLASS.permissions.hasPriv(contents, FIRSTCLASS.permissions.ACL.EDITACL) == FIRSTCLASS.permissions.ACL.EDITACL) { subheader.innerHTML = "" + FIRSTCLASS.locale.workflows.memberlist.toolbar.edit + ""; } else { subheader.innerHTML = "" + FIRSTCLASS.locale.workflows.memberlist.toolbar.noedit + ""; } FIRSTCLASS.ui.rightSideBar.updateBoxSubHeader(FIRSTCLASS.locale.community.members.lbl, subheader); that._config.acl = contents; //that._appTB.reconfigure(null, contents); break; case "typedef": if (contents.isalias == 0 && !that._typedefConfigured) { that._membersAppAction = true; FIRSTCLASS.ui.rightSideBar.updateBoxAction(FIRSTCLASS.locale.community.members.lbl, false, false, 'members'); // FIRSTCLASS.ui.rightSideBar.updateBoxAction(FIRSTCLASS.locale.community.members.lbl, that._membersAppAction); } that._typedefConfigured = true; that._config.isalias = contents.isalias; break; case "tags": if (that._dataSource._overrideTags && contents != that._dataSource._overrideTags) { contents = that._dataSource._overrideTags; } if (contents.length > 0) { if (that._lasttags && contents != that._lasttags || !that._lasttags) { var cloud = FIRSTCLASS.ui.parseServerTags(contents); if (cloud.length > 0) { that._tags.innerHTML = FIRSTCLASS.ui.generateCloud(cloud); FIRSTCLASS.ui.Dom.updateViewportBounds(); //that.resizeEvent(); } that._lasttags = contents; } } break; case "icon": if (that.applyIconAsProfilePicture && that.applyIconAsProfilePicture != 2) { FIRSTCLASS.ui.navBar.setProfilePicture(contents.uri, "about"); that._iconuri = contents.uri; that.applyIconAsProfilePicture = 2; } break; case "skin": if (!that.skinned && that._isActive) { FIRSTCLASS.ui.skin.set(contents); that.skinned = true; that._skin = contents; } break; case "stats": that._stats = contents; var str = ""; if (that._alias) { str = "" + FIRSTCLASS.lang.mlesc(that._alias) + " "; } str = str + "(" + that._stats.lConfSubscribers + " " + FIRSTCLASS.locale.community.summ.subscribers + ", " + that._stats.lConfPosts + " " + FIRSTCLASS.locale.community.summ.posts + ", " + that._stats.lConfHits + " " + FIRSTCLASS.locale.community.summ.views + ")"; FIRSTCLASS.ui.navBar.setBottomText(str); break; case "alias": that._alias = contents; var str = "" + FIRSTCLASS.lang.mlesc(contents) + ""; if (that._stats) { str = str + " (" + that._stats.lConfSubscribers + " " + FIRSTCLASS.locale.community.summ.subscribers + ", " + that._stats.lConfPosts + " " + FIRSTCLASS.locale.community.summ.posts + ", " + that._stats.lConfHits + " " + FIRSTCLASS.locale.community.summ.views + ")"; } FIRSTCLASS.ui.navBar.setBottomText(str); break; case "folderid": that._folderid = contents; default: } }, filter: function(dataname) { switch (dataname) { case "name": case "icon": case "tags": case "objid": case "skin": case "alias": case "stats": case "folderid": return true; case "acl": if (!that._aclConfigured) { return true; } case "typedef": if (!that._typedefConfigured) { return true; } default: return false; } } }); this._domElem.innerHTML = ""; this._tabView.appendTo(this._config.div); //YAHOO.util.Event.addListener(window, 'resize', function(evt) { that.resizeEvent(); }); //FIRSTCLASS.session.addHistoryEntry(this.generateHistoryEntry(FIRSTCLASS.locale.community.feed.lbl, this)); if (config.params.tab && !config.params.itemthread) { this.switchToApplication(config.params.tab); } else { this.switchToApplication("Feed"); } this._config.onready(); this.activate(); var showdispatched = false; if (config.params.itemthread){ if (config.params.messageid) { this.navToItem(config.params.itemthread, config.params.messageid, config.params.showoncomplete); showdispatched = true; } else { showdispatched = true; this.navToItemByThread(config.params.itemthread, config.params.showoncomplete); } } if (config.params.showoncomplete && !showdispatched) { FIRSTCLASS.util.revealContents(); } FIRSTCLASS.ui.navBar.setProfileStatus(false); }; FIRSTCLASS.apps.Community.instance = 0; FIRSTCLASS.apps.Community.prototype.activate = function () { this._isActive = true; FIRSTCLASS.session.setActiveObject(this._config.baseUrl); // FIRSTCLASS.session.setActiveApplication(this, "feed"); FIRSTCLASS.ui.Dom.replaceContentsWithElement(this._parentDiv, this._domElem); this.activateSideBar(); this.resizeEvent(); // this._listView.activate(); this._dataSource.activate(); if (this._memberlistlv) { this._memberlistlv.activate(); this._memberlistds.activate(); } FIRSTCLASS.ui.setDocumentTitle(this._title); YAHOO.util.Dom.setStyle(document.body, "height", "100%"); YAHOO.util.Dom.setStyle(document.body, "overflow", "hidden"); if (this._iconuri) { FIRSTCLASS.ui.navBar.setProfilePicture(this._iconuri, "about"); } if (this._skin) { FIRSTCLASS.ui.skin.set(this._skin); } }; FIRSTCLASS.apps.Community.prototype.__fcAppName = "FIRSTCLASS.apps.Community"; FIRSTCLASS.apps.Community.prototype.deactivate = function(internal) { // this._listView.deactivate(); if (!internal) { FIRSTCLASS.ui.skin.clear(); this._dataSource.deactivate(); if (this._memberlistlv) { this._memberlistlv.deactivate(); this._memberlistds.deactivate(); } YAHOO.util.Dom.setStyle(document.body, "height", ""); YAHOO.util.Dom.setStyle(document.body, "overflow", ""); for (var i in this._subApps) { if (this._subApps[i].instance && this._subApps[i].instance.deactivate) { this._subApps[i].instance.deactivate(true); } } } this._isActive = false; FIRSTCLASS.ui.MiniProfile.hideBoxNow(); }; FIRSTCLASS.apps.Community.prototype.dispose = function() { if (this._config.logTime && false) { this._config.logTime("Community app dispose called"); } var that = this; // window.setTimeout(function() { for (var i in that._subApps) { if (that._subApps.instance && that._subApps.instance.dispose) { that._subApps.instance.dispose(); delete that._subApps.instance; } } if (that._memberlistlv) { that._memberlistlv.dispose(); delete that._memberlistlv; that._memberlistds.dispose(); delete that._memberlistds; } /* if (this._listView) { this._listView.dispose(); delete this._listView; }*/ delete that._tabs; if (that._config.logTime && false) { that._config.logTime("Community app dispose finished"); } // }, 10); if (this._config.logTime && false) { this._config.logTime("Community app dispose dispatched to timeout"); } this._domElem.innerHTML = ""; }; FIRSTCLASS.apps.Community.prototype.isSwitchingToSubApp = function() { var curhist = FIRSTCLASS.session.getCurrentHistoryEntry(); if (!curhist || !curhist.app) { var hist = FIRSTCLASS.session.currentHistoryIndex.key; var myCIDStr = "__Open-Conf/CID" + this._config.params.lconfcid; if (hist.indexOf(myCIDStr) == 0) { return true; } return false; } var app = curhist.app; var found = false; for ( var index = 0; index < this._subApps.length; index++) { var tmpApp = this._subApps[index]; if (tmpApp.instance && tmpApp.instance == app) { found = true; break; } } return found; }; FIRSTCLASS.apps.Community.prototype.isSubApp = function(app) { if (app === this) { return true; } for (var i in this._subApps) { if (this._subApps[i].instance && this._subApps[i].instance === app) { return true; } } return false; }; FIRSTCLASS.apps.Community.prototype.isSameBaseApp = function(uri) { var parts = uri.split("/"); if (this._config.params.lconfcid) { if (uri.indexOf("__Open-Conf/CID" + this._config.params.lconfcid)) { return true; } } else { var url = FIRSTCLASS.lang.extractSessionPath(that._config.baseUrl).replace("FAV1", "FV1").replace("FOV1", "FV1").replace("FLV1", "FV1"); if (uri.indexOf(url) >= 0) { return true; } } return false; }; FIRSTCLASS.apps.Community.prototype.generateHistoryEntry = function(tabName,instance,row, toitem) { var that = this; var url = FIRSTCLASS.session.baseURL + FIRSTCLASS.lang.extractSessionPath(that._config.baseUrl); if (this._config.params.lconfcid) { url = FIRSTCLASS.session.baseURL + "__Open-Conf/CID" + this._config.params.lconfcid; } else { var uri = url.replace("FAV", "FV").replace("FOV", "FV").replace("FLV", "FV"); var idx = uri.indexOf(FIRSTCLASS.session.baseURL); if (idx >= 0 && uri.length - idx > FIRSTCLASS.session.baseURL.length) { uri = uri.substr(idx+FIRSTCLASS.session.baseURL.length); } url = FIRSTCLASS.session.baseURL + uri; } url = FIRSTCLASS.lang.ensureSlashUrl(url); if (row) { url += FIRSTCLASS.util.generateThreadContextParameter(row, toitem); } if (tabName) { url = url + "?Tab=" + tabName; } return { "uri": url, "app":instance, activate:function() { that.activate(); that._tabView.set("activeTab", that._tabs[tabName]); }, deactivate:function() { that.deactivate(that.isSwitchingToSubApp()); }, dispose: function() { that.dispose(); } }; }; /** * loads the application for a given tab * * @Method Community.loadApplication * @param {string} tabName the name of the tab */ FIRSTCLASS.apps.Community.prototype.switchToApplication = function(internalTabName, showoncomplete) { var tab = this._tabs[internalTabName]; if (tab) { this._showoncomplete = showoncomplete; this._tabView.set("activeTab", tab); } }; FIRSTCLASS.apps.Community.prototype.loadApplication = function(tabName, activate, rowToOpen, showoncomplete) { if (typeof activate == "undefined") { activate = true; } if (this._config.logTime) { this._config.logTime("Community loadApplication: " + tabName); } /* var tabid = false; for (var i in this._subApps) { if (this._subApps[i].label == tabName) { tabid = this._subApps[i].tabName; break; } } if (!tabid) { return; } var tab = this._tabs[tabid];*/ var tab = this._tabs[tabName]; var that = this; this._rowToOpen = rowToOpen; for(var i = 0; i < this._subApps.length; i++) { var j = i; if (this._subApps[j].tabName == tabName) { FIRSTCLASS._loader.require([this._subApps[j].app]); FIRSTCLASS._loader.onSuccess = function(o) { if (that._config.logTime) { that._config.logTime("Community loadApplication finished: " + tabName); } var app = that._subApps[j]; var created = false; if (!app.instance) { created = true; var tabElem = tab.get("contentEl"); var domElem = document.createElement("div"); if (app.contentPane) { var contentPane = FIRSTCLASS.ui.widgets.buildContentPane(domElem, 'fcTabContentPane'); if (activate) { tabElem.appendChild(contentPane); } else { app.domContents = document.createElement("div"); app.domContents.appendChild(contentPane); } } else { if (activate) { tabElem.appendChild(domElem); } else { app.domContents = document.createElement("div"); app.domContents.appendChild(domElem); } } /*domElem.style.overflow = "auto";*/ domElem.style.height = "100%"; var config = { domElement: domElem, dataSource: that._dataSource, onResize:function() { that.resizeEvent(); }, containerBaseUrl: that._config.baseUrl, rowToOpen: that._rowToOpen, threadToOpen: that._config.params.itemthread, community: that }; if (that._config.logTime) { config.logTime = that._config.logTime; } if (that._config.params.fromSearch) { config.fromSearch = that._config.params.fromSearch; } switch (tabName) { case "Feed": case FIRSTCLASS.locale.community.feed.lbl: // app.instance = that; // do nothing; // break; // case "Discussion": app.instance = new FIRSTCLASS.apps.Discussion(config); break; case "Documents": case FIRSTCLASS.locale.community.docs.lbl: app.instance = new FIRSTCLASS.apps.Documents(config); break; case "Wiki": case FIRSTCLASS.locale.community.wiki.lbl: app.instance = new FIRSTCLASS.apps.Wiki(config); break; /* case "Tasks": app.instance = new FIRSTCLASS.apps.Tasks(config); break; case "Calendar": app.instance = new FIRSTCLASS.apps.Calendar(config); break;*/ default: break; } } that._rowToOpen = null; var histent = FIRSTCLASS.session.getCurrentHistoryEntry(); if (activate && app.instance && (histent && histent.app != app.instance || !histent)) { FIRSTCLASS.session.addHistoryEntry(that.generateHistoryEntry(tabName, app.instance, rowToOpen)); } if (activate && app.instance && app.instance.activate) { /*that.switchToApplication(tabName, showoncomplete);*/ app.instance.activate(); if (showoncomplete && !app.instance.showRowInContext) { FIRSTCLASS.util.revealContents(); } } if (rowToOpen && activate && app.instance.showRowInContext) { var oncomplete = false; if (showoncomplete) { oncomplete = FIRSTCLASS.util.revealContents; } app.instance.showRowInContext(rowToOpen, oncomplete); if (tabName != "Feed") { that._subApps[0].instance.setShowRowInContextPadText(); } } }; FIRSTCLASS._loader.insert(); return; } } }; FIRSTCLASS.apps.Community.prototype.resizeEvent = function(event, recursive) { var appOverride = false; // check for sub-app override var app = FIRSTCLASS.session.getCurrentHistoryEntry(); if (app) { app = app.app; } var appUpdate = false; if (typeof recursive == "undefined" || recursive) { for (var i in this._subApps) { if ((this._subApps[i].instance) && this._subApps[i].instance == app) { if (typeof this._subApps[i].instance.myResizeEvent == "function") { this._subApps[i].instance.myResizeEvent(); appOverride = true; break; } if (typeof this._subApps[i].instance.updateHeight == "function") { appUpdate = true; } } } } var viewport = FIRSTCLASS.ui.Dom.getViewportBounds(); if (!this.sbTop) { this.sbTop = YAHOO.util.Dom.getY($("fcRightSideBar")); } // these are hard coded values, change them if the ui changes var ypos2 = 124; var xpos2 = 20; var ypos = 114; var sbTop = this.sbTop; if (FIRSTCLASS.skin && FIRSTCLASS.skin.community && FIRSTCLASS.skin.community.sidebars && FIRSTCLASS.skin.community.sidebars.right && FIRSTCLASS.skin.community.sidebars.right.bottompad) { sbTop += FIRSTCLASS.skin.community.sidebars.right.bottompad; } FIRSTCLASS.ui.rightSideBar.adjustBoxHeights(viewport.ht-sbTop); var sbwid = viewport.wd*.2; if (sbwid < 180) { sbwid = 180; } FIRSTCLASS.session.RuntimeCSS.updateRule('.fcListViewRow .fcBody', "max-width: " + (viewport.wd - sbwid - 200) + "px;overflow-x:auto;overflow-y:hidden;"); var editwidth = (viewport.wd - sbwid - 90); FIRSTCLASS.session.RuntimeCSS.updateRule('.fcInlineComposeMessage .fcEditorContainer', "width: " + editwidth + "px;"); FIRSTCLASS.session.RuntimeCSS.updateRule('.fclvrowformdoc .fcEditorContainer', "width: " + (editwidth - 100) + "px;"); FIRSTCLASS.session.RuntimeCSS.updateRule('.fcWikiContent .fcEditorContainer', "width: " + (editwidth + 38) + "px;"); FIRSTCLASS.session.RuntimeCSS.updateRule('.fcDocSelHistory .fcEditorContainer', "width: " + (editwidth - 64) + "px;"); //FIRSTCLASS.session.RuntimeCSS.updateRule('.uncollapser', "max-width: " + (viewport.wd - sbwid - 200) + "px;"); if (!appOverride) { // contents var tab = this._tabView.get('activeTab'); var tabcont = tab.get('contentEl'); //var ypos = YAHOO.util.Dom.getY(tabcont); //console.log('ypos is ' + ypos) var newheight = viewport.ht-ypos-1; if (ypos) { var appContent = FIRSTCLASS.ui.Dom.getChildByClassName("fcAppScrollingContent", tabcont); if (appContent) { /*var ypos2 = YAHOO.util.Dom.getY(appContent); var xpos2 = YAHOO.util.Dom.getX(appContent); console.log ("with appContent"); console.log("ypos2 is " + ypos2); console.log("xpos2 is " + xpos2);*/ newheight = viewport.ht - ypos2 - 1; if (newheight <= 0) { return; } var newwidth = viewport.wd - xpos2 - 1; if (YAHOO.env.ua.ie) { YAHOO.util.Dom.setStyle(appContent, "overflow-y", "scroll"); YAHOO.util.Dom.setStyle(appContent, "overflow-x", "hidden"); } else { YAHOO.util.Dom.setStyle(appContent, "overflow", "auto"); } YAHOO.util.Dom.setStyle(appContent, "height", newheight+"px"); //YAHOO.util.Dom.setStyle(appContent, "width", newwidth-FIRSTCLASS.ui.rightSideBar.getWidth()+"px"); } else { var tabContent = FIRSTCLASS.ui.Dom.getChildByClassName("fcContentWrapper", tabcont); if (tabContent) { /*var ypos2 = YAHOO.util.Dom.getY(tabContent); var xpos2 = YAHOO.util.Dom.getX(tabContent); console.log ("with tabContent"); console.log("ypos2 is " + ypos2); console.log("xpos2 is " + xpos2);*/ newheight = viewport.ht - ypos2 - 1; if (newheight <= 0) { return; } var newwidth = viewport.wd - xpos2 - 1; YAHOO.util.Dom.setStyle(tabContent, "overflow", "auto"); YAHOO.util.Dom.setStyle(tabContent, "height", newheight+"px"); //YAHOO.util.Dom.setStyle(tabContent, "width", newwidth-FIRSTCLASS.ui.rightSideBar.getWidth()+"px"); } else { if (newheight <= 0) { return; } /* YAHOO.util.Dom.setStyle(tabcont, "overflow", "auto"); YAHOO.util.Dom.setStyle(tabcont, "height", newheight+"px");*/ } } if (appUpdate) { app.updateHeight(newheight); } } else { if (appUpdate) { app.updateHeight(newheight); } } } var fcMain = $("fcMain"); if (fcMain) { YAHOO.util.Dom.setStyle(fcMain, "height", viewport.ht+"px"); } }; FIRSTCLASS.apps.Community.prototype.getProfileCallbacks = function() { var that = this; var profilecallbacks = { onerror: function() { that.applyIconAsProfilePicture = true; } }; return profilecallbacks; }; FIRSTCLASS.apps.Community.prototype.activateSideBar = function() { var that = this; if(!this._memberlistds) { this._memberlistds = new FIRSTCLASS.util.DataSource( { symbioticDataSource: {dataSource:that._dataSource, key:"subscribers"}, itemrequest: false, compareRows:function(row1, row2) { return row1.online == row2.online; }, isSameRow: function(row1, row2) { return row1.uid == row2.uid; } } /*{ containerBaseUrl:this._config.baseUrl+"__ListSubscribers", reloadFullOnPoll: true, compareRows:function(row1, row2) { return row1.online == row2.online; }, isSameRow: function(row1, row2) { return row1.uid == row2.uid; } }*/); /*var rlistener = { onRow: function(row) { if (row.online != null) { FIRSTCLASS.session.UserStatuses.updateStatus(row.cid, row.online); } }, onFillFinished: function() { FIRSTCLASS.session.UserStatuses.generateCSS(); } }; this._memberlistds.addRowListener(rlistener);*/ var OnlineStatus = ["Offline","Online"]; this._actions = document.createElement("div"); this._memberlist = document.createElement("div"); YAHOO.util.Dom.setStyle(this._memberlist, 'overflow', 'hidden'); YAHOO.util.Dom.setStyle(this._memberlist, 'padding-right', '2px'); // allow mouseout to be called when exiting via scrollbar var memberlistcfg = { domElement: this._memberlist, dataSource: this._memberlistds, threading: { format: FIRSTCLASS.layout.ThreadHandler.types.NONE, sortfunc: function(row1, row2) { row1.parseddate = new Date(); if (row1.what == 11) { row1.parseddate.setTime((parseInt(row1.lastin) + (row1.online*1000000) + ((row1.uid == FIRSTCLASS.session.user.cid)?1000000:0) - 2082844800)*1000); } else { row1.parseddate.setTime(0); } row2.parseddate = new Date(); if (row2.what == 11) { row2.parseddate.setTime((parseInt(row2.lastin) + (row2.online*1000000) + ((row2.uid == FIRSTCLASS.session.user.cid)?1000000:0) - 2082844800)*1000); } else { row2.parseddate.setTime(0); } if (row1.parsedDate < row2.parsedDate) { return 1; } else if (row1.parsedDate == row2.parsedDate) { return 0; } else { return -1; } } }, compareRows:function(row1,row2) { return row1.online == row2.online && row1.what == row2.what && row1.lastin == row2.lastin; }, keepRowsSorted: true, rowHandler: new FIRSTCLASS.layout.UserListHandler( that._memberlistds, function() { return typeof that._membersAppAction != "undefined"; }, false, function(bdelete, row) { bdelete.setAttribute('fcid', 'removename'); bdelete.setAttribute('fcattrs', row.uid); } ) }; this._memberlistlv = new FIRSTCLASS.layout.ListView(memberlistcfg); this._tags = document.createElement("div"); var tags = [{tag:FIRSTCLASS.locale.community.tag.info, weight:1, clickable:false}]; this._tags.innerHTML = FIRSTCLASS.ui.generateCloud(tags); //this._tags.fixedHeight = 100; this._tags.maxHeight = 200; //this._tags.minHeight = 100; } FIRSTCLASS.ui.leftSideBar.hide(); FIRSTCLASS.ui.leftSideBar.resetApplicationBoxContents(); FIRSTCLASS.ui.rightSideBar.show(); FIRSTCLASS.ui.rightSideBar.resetApplicationBoxContents(); FIRSTCLASS.ui.rightSideBar.addApplicationBox(this._actions, FIRSTCLASS.locale.community.actions.lbl); if (this._membersAppAction) { FIRSTCLASS.ui.rightSideBar.addApplicationBox(this._memberlist, FIRSTCLASS.locale.community.members.lbl, false /*this._membersAppAction*/, false, 35, false, true, 'members'); } else { FIRSTCLASS.ui.rightSideBar.addApplicationBox(this._memberlist, FIRSTCLASS.locale.community.members.lbl, false, false, 35, false, true); } FIRSTCLASS.ui.rightSideBar.addApplicationBox(this._tags, FIRSTCLASS.locale.community.tag.lbl); FIRSTCLASS.ui.rightSideBar.adjustBoxHeights(); //FIRSTCLASS.ui.navBar.setProfileStatus(false); }; FIRSTCLASS.apps.Community.prototype.loadMembersApp = function() { var domElem = document.createElement("div"); var burl = FIRSTCLASS.lang.ensureSlashUrl(FIRSTCLASS.session.baseURL) + "__MemForm/"+FIRSTCLASS.opCodes.FormSave;//+"?FormID=11215&Clear=0";// // var burl = this._config.baseUrl+"__ListSubscribers"; if (!this.membersApp) { this.membersApp = new FIRSTCLASS.apps.Members({baseUrl:burl, domElement:domElem, objid:this._objid, title:this._title, community:this._config.baseUrl, folderid: this._folderid}); } else { if (!this.membersApp.isVisible()) { this.membersApp.startWorkflow(); } } }; // navigate to the target url, which is an object in this community FIRSTCLASS.apps.Community.prototype.navToItemUrl = function(handler, target, showoncomplete) { // query DS for item's row var itemSpec = handler.getName(target); var dsr; var rows = this._dataSource.query("name", itemSpec, true); if (!rows) { rows = this._dataSource.query("uri",itemSpec,true); } if (rows && rows.length > 0) { dsr = rows[0][1]; } if (dsr) { // got it this.openRowInContext(dsr, showoncomplete); } else { // ask for it var that = this; this._dataSource.getRowByName(itemSpec,{ success: function(row) {that.openRowInContext(row, showoncomplete);}, failure: function() { that._dataSource.getRowBySysid(itemSpec, { success: function(row) {that.openRowInContext(row, showoncomplete);}, failure: function() { alert("Could not open internal link!"); } }); } }); } }; FIRSTCLASS.apps.Community.prototype.navToItemByCID = function(cid, showoncomplete) { // query DS for item's row var dsr; var rows = this._dataSource.query("cid", cid, true); if (rows && rows.length > 0) { dsr = rows[0][1]; } if (dsr) { // got it this.openRowInContext(dsr, showoncomplete); } else { // ask for it var that = this; this._dataSource.getRowByCID(cid,{ success: function(row) {that.openRowInContext(row, showoncomplete);}, failure: function() { alert("Could not open internal link!"); } }); } }; FIRSTCLASS.apps.Community.prototype.navToItem = function(tid, messageid, showoncomplete) { // query DS for item's row var dsr; var that = this; var rows = this._dataSource.query("uid", messageid, true); if (rows && rows.length > 0) { dsr = rows[0][1]; } if (dsr) { // got it this.openRowInContext(dsr, showoncomplete); } else { // ask for it var that = this; this._dataSource.fetchRowsByThread(tid,{ completed: function() { rows = that._dataSource.query("threadid", tid, true); if (rows && rows.length > 0) { for (var i in rows) { if (rows[i][1].uid == messageid) { dsr = rows[i][1]; that.openRowInContext(dsr, showoncomplete); return; } } } FIRSTCLASS.util.revealContents(); }, failed: function() { // alert("Could not open internal link!"); FIRSTCLASS.util.revealContents(); } }); } }; FIRSTCLASS.apps.Community.prototype.navToItemByThread = function(tid, showoncomplete) { // query DS for item's row var dsr = false; var that = this; var rows = this._dataSource.query("threadid", tid, true); if (rows && rows.length > 0) { dsr = rows[0][1]; } if (dsr) { // got it this.openRowInContext(dsr, showoncomplete); } else { // ask for it var that = this; this._dataSource.fetchRowsByThread(tid,{ completed: function() { rows = that._dataSource.query("threadid", tid, true); for (var i = rows.length-1; i >= 0; i--) { if ((rows[i][1].col8091 == FIRSTCLASS.objTypes.odocument && rows[i][1].col8091 == rows[i][1].typedef.objtype) || rows[i][1].col8091 != FIRSTCLASS.objTypes.odocument) { dsr = rows[i][1]; break; } } if (!dsr && rows && rows.length > 0) { dsr = rows[0][1]; } if (dsr) { that.openRowInContext(dsr, showoncomplete); } FIRSTCLASS.util.revealContents(); }, failed: function() { alert("Could not open internal link!"); } }); } }; FIRSTCLASS.apps.Community.prototype.openRowInContext = function(row, showoncomplete) { // choose sub-app for the item var subApp = this.chooseNativeSubApp(row); // if current, open the item /* if (subApp.toLowerCase() == FIRSTCLASS.session._activeAppName.toLowerCase()) { // just open the item FIRSTCLASS.session._activeApplication.openItem(row); } else {*/ // open sub-app with highlighted row this.loadApplication(subApp, true, row, showoncomplete); // } }; FIRSTCLASS.apps.Community.prototype.chooseNativeSubApp = function(row) { var testType = row.typedef.objtype; // check objtype or original objtype if there is one if (row.col8091) { testType = row.col8091; } if (row.replyobjtype) { testType = row.replyobjtype; } var subApp = FIRSTCLASS.locale.community.feed.lbl; if (row.linkinfo) { testType = FIRSTCLASS.objTypes.file; } switch (testType) { case FIRSTCLASS.objTypes.confitem: case FIRSTCLASS.objTypes.message: subApp = "Feed"; break;//FIRSTCLASS.locale.community.feed.lbl; break; case FIRSTCLASS.objTypes.file: subApp = "Documents"; break;//FIRSTCLASS.locale.community.docs.lbl; break; case FIRSTCLASS.objTypes.odocument: subApp = "Wiki"; break;//FIRSTCLASS.locale.community.wiki.lbl; break; default: subApp = "Feed";//FIRSTCLASS.locale.community.feed.lbl; } return subApp; }; YAHOO.register("fcCommunity", FIRSTCLASS.apps.Community, {version: "0.0.1", build: "1"}); // Discussion.js - implementation of the Discussion sub-application FIRSTCLASS.apps.Discussion = function(config) { if (config.logTime) { config.logTime("Discussion App Loaded"); } this._domElement = config.domElement; this._dataSource = config.dataSource; this._instance = FIRSTCLASS.apps.Discussion._nInstances++; this._config = config; this._isActive = true; var that = this; if (!FIRSTCLASS.apps.Discussion.prototype._rowSubElement) { FIRSTCLASS.apps.Discussion.prototype._rowSubElement = document.createElement("div"); FIRSTCLASS.apps.Discussion.prototype._rowSubElement.innerHTML = "
"; } if (!this._appTBElement) { this._appTBElement = document.createElement("div"); this._rightAppTBElement = document.createElement("div"); var watched = FIRSTCLASS.session.desktop.isContainerBeingWatched(that._config.containerBaseUrl); this._config.watched = watched; this._config.community._config.watched = watched; var appTBCfg = { domElement:this._appTBElement, vertical: true, buttons: [ { id: "fcFeedSubscribe"+this._instance, label: FIRSTCLASS.locale.community.feed.actions.subscribe, fcid: 'subscribe', condition: function() { if (typeof config.fromSearch != "undefined") { return config.fromSearch; } return false; } }, { id: "fcFeedClearUnread"+this._instance, label: FIRSTCLASS.locale.toolbars.readall, fcid: 'clearunread' }, { id: "fcFeedNewTopic"+this._instance, label: FIRSTCLASS.locale.community.feed.actions.topic, fcid: 'topic', priv: FIRSTCLASS.permissions.ACL.SEND }/*, { id: "fcFeedNewQuestion"+this._instance, label: FIRSTCLASS.locale.community.feed.actions.question, fcid: 'question', priv: FIRSTCLASS.permissions.ACL.SEND }*/, { id: "fcFeedUpload"+this._instance, label: FIRSTCLASS.locale.toolbars.upload, fcid: 'upload', priv: FIRSTCLASS.permissions.ACL.CREATE }, { id: "fcFeedSetup"+this._instance, label: FIRSTCLASS.locale.community.feed.actions.setup, fcid: 'about', customizer: function(el, config, acl) { var isalias = false; if (typeof that._config.community._config.isalias != "undefined" && parseInt(that._config.community._config.isalias) == 1) { isalias = true; } if (isalias && FIRSTCLASS.permissions.hasPriv(acl, FIRSTCLASS.permissions.ACL.MODERATOR) == 0) { el.innerHTML = "about this community"; } } }/*, { id: "fcFeedContainerWatch"+this._instance, label: (watched?FIRSTCLASS.locale.community.feed.actions.unwatch:FIRSTCLASS.locale.community.feed.actions.watch), fcid: 'feeds', condition: function() { if (typeof config.fromSearch != "undefined") { return !config.fromSearch; } return true; } }*/] }; this._appTB = new FIRSTCLASS.ui.toolBar(appTBCfg); }; this._lvDomElement = document.createElement("div"); this._newMessageInlineElement = document.createElement("div"); YAHOO.util.Dom.addClass(this._newMessageInlineElement, 'fcInlineComposeMessage'); this._domElement.appendChild(this._newMessageInlineElement); YAHOO.util.Dom.addClass(this._lvDomElement, "fcAppScrollingContent"); YAHOO.util.Dom.addClass(this._lvDomElement, "fcDiscloseSingleLine"); this._domElement.appendChild(this._lvDomElement); var lvConfig = { rowHandler: this, domElement: this._lvDomElement, dataSource: this._dataSource, fillOnScroll:true, threading: { format: "bythread", sortfunc: this._rowSort, threadsortfunc: this.rowSort, originRowIsHeader: true, collapseRead: true, displayThreadContributors: true }, listenForNavKeys: true, selectionFollowsScroll: true, rowFilter: this.getRowFilter(), padHeight: true, padText: FIRSTCLASS.locale.community.loading, drawOffScreen: false, onFillFinished: function() { that.onListViewFillFinished(); } }; if (config.threadToOpen) { this._filterThread = config.threadToOpen; lvConfig.fillOnScroll = false; } if (config.logTime) { lvConfig.logTime = config.logTime; } if(config.onResize) { lvConfig.onResize = config.onResize; } this._myFeed = new FIRSTCLASS.layout.Feed( { listView:null, dataSource:config.dataSource, headerClickFunc: function(row) { config.community.openRowInContext(row); }, thumbnailClickLoadsItem: true }); this._listView = new FIRSTCLASS.layout.ListView(lvConfig); this._dataSource.addDataListener({ onHeaderData:function(data, contents) { if (!that._filteringByThread) { if (that._dataSource.hasMoreRows()) { that._listView.updatePadText(FIRSTCLASS.locale.community.loading); } else { that._listView.updatePadText(FIRSTCLASS.locale.community.nomore); } } switch (data) { case "acl": that._appTB.reconfigure(null, contents); break; case "numitems": /*if (contents.unread && !that._config.community._unreadModified) { that._config.community._unread = contents.unread; FIRSTCLASS.ui.navBar.setProfileUnread(that._config.community._unread, that._config.community._config.baseUrl); if (that._desktopRow) { that._desktopRow.status.unread = that._config.community._unread; FIRSTCLASS.apps.Desktop.instance._dataSource.notifyRowChanged(that._desktopRow); } }*/ break; case "cid": //that._config.community._config.params.lconfcid = parseInt(contents); default: } }, filter: function(dataname) { switch (dataname) { case "numitems": case "cid": return true; case "acl": if (!that._aclConfigured) { return true; } return false; case "alias": return true; default: return false; } } }); this._myFeed.listView = this._listView; // punch in after FIRSTCLASS.session.setActiveApplication(this, "discussion"); if (config.rowToOpen) { this.showRowInContext(config.rowToOpen); } if (config.logTime) { config.logTime("Discussion App Load Finished"); } }; FIRSTCLASS.apps.Discussion.prototype.__fcAppName = "FIRSTCLASS.apps.Discussion"; FIRSTCLASS.apps.Discussion.prototype.dispose = function() { this._domElement.innerHTML = ""; }; FIRSTCLASS.apps.Discussion.prototype.getCommunity = function() { return this._config.community; }; // class variables FIRSTCLASS.apps.Discussion._nInstances = 0; FIRSTCLASS.apps.Discussion.prototype._dataSource = null; FIRSTCLASS.apps.Discussion.prototype._domElement = null; FIRSTCLASS.apps.Discussion.prototype._listView = null; FIRSTCLASS.apps.Discussion.prototype._myFeed = null; FIRSTCLASS.apps.Discussion.prototype._rowSubElement = null; FIRSTCLASS.apps.Discussion.prototype.isRelatedApp = function(app) { return this._config.community.isSubApp(app); }; FIRSTCLASS.apps.Discussion.prototype.resizeEvent = function(event) { this._config.community.resizeEvent(event,false); }; FIRSTCLASS.apps.Discussion.prototype.setEditorActive = function() { this.hasEditorActive = true; this._myFeed.setEditorActive(); } FIRSTCLASS.apps.Discussion.prototype.clearEditorActive = function() { this.hasEditorActive = false; this._myFeed.clearEditorActive(); } FIRSTCLASS.apps.Discussion.prototype.isSafeToNavigate = function() { if (this.hasEditorActive) { return false; } else { return !this._myFeed.hasEditorActive; } }; FIRSTCLASS.apps.Discussion.prototype.overrideSafeToNavigate = function() { this._newMessageInlineElement.innerHTML = ""; if (this._myFeed.hasEditorActive) { this._myFeed.clearForm(this._myFeed.hasEditorActive); } }; FIRSTCLASS.apps.Discussion.prototype.updateHeight = function(newheight) { this._listView.updatePadHeight(newheight); }; FIRSTCLASS.apps.Discussion.prototype.acceptMemberRequestStep1 = function(fcevent) { var that = this; var cbs = { success: function(response) { var js = {}; try { if (!that._myFeed._selectedRow.memberAccepted) { js = FIRSTCLASS.lang.JSON.parse(response.responseText); var formcontainer = document.createElement("div"); var uri = FIRSTCLASS.session.baseURL + "__MemForm/"+FIRSTCLASS.opCodes.FormSave+"?FormID=11215&Clear=0&Templates=Members"; var html = ["
"]; html.push(""); html.push(""); html.push(""); html.push(""); html.push("
"); formcontainer.innerHTML = html.join(""); FIRSTCLASS.util.submitForm(formcontainer.firstChild); fcevent.target.innerHTML = FIRSTCLASS.locale.workflows.acceptmember.accepted; fcevent.target.setAttribute('fcid',''); that._dataSource.updateFieldData(that._myFeed._selectedRow, [{id:5, type:"SHORT", value:23043}]); that._myFeed._selectedRow.memberAccepted = true; } } catch(e) { } }, failure: function(response) { fcevent.target.innerHTML = FIRSTCLASS.locale.workflows.acceptmember.failed; } }; YAHOO.util.Connect.asyncRequest('GET', that._config.containerBaseUrl + "?Templates=JS&Close=-2&Both=0-1", cbs); }; FIRSTCLASS.apps.Discussion.prototype.eventHandlers = { click: { subscribe: function(that, fcevent) { YAHOO.util.Connect.asyncRequest('GET', that._config.containerBaseUrl + "?Subscribe=1"); that._config.fromSearch = false; that._appTB.reconfigure(null, that._dataSource.getAcl()); FIRSTCLASS.session.desktop._dataSource.fetchRows(false, false, false, false, true); return true; }, clearunread: function(that, fcevent) { that._dataSource.markAllAsRead(false); that._unread = 0; FIRSTCLASS.ui.navBar.setProfileUnread(0); }, topic: function(that, fcevent) { if (!that.hasEditorActive && FIRSTCLASS.session.canNavigateAway()) { var msgCfg = { callback: that, element: that._newMessageInlineElement, op: "__Send", baseURL: that._config.containerBaseUrl, objType: FIRSTCLASS.objTypes.message, formID: 21000, formElId: "fcDocForm", bodyType: "HTML", quoteText: null, sendTo: null, initHeight: "240px", showAddr: false, tbType: "message", params: "InitialText=", dataSource: that._dataSource, maxImage: 480, callback: { onDisplay: function() { if (YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 7) { that._listView.disableScroll(); } }, onFail: function(obj) { that.clearEditorActive(); if (that._msgEditor && that._msgEditor !== null) { that._msgEditor.destroy(); that._msgEditor = null; } if (obj && obj.error) { FIRSTCLASS.ui.navBar.updateShoutBox(FIRSTCLASS.locale.errors.getErrorString(obj.error)); } that._newMessageInlineElement.innerHTML = ""; if (YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 7) { that._listView.allowScroll(); } }, onSave: function() { that.clearEditorActive(); if (that._msgEditor && that._msgEditor !== null) { that._msgEditor.destroy(); that._msgEditor = null; } that._newMessageInlineElement.innerHTML = ""; if (YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 7) { that._listView.allowScroll(); } }, onCancel: function() { that.clearEditorActive(); if (that._msgEditor && that._msgEditor !== null) { that._msgEditor.destroy(); that._msgEditor = null; } that._newMessageInlineElement.innerHTML = ""; if (YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 7) { that._listView.allowScroll(); } } } }; that._msgEditor = new FIRSTCLASS.util.Message(msgCfg); if (that._msgEditor !== null) { that.setEditorActive(); that._listView.clearSelection(); } } }, question: function(that, fcevent) { if (!that.hasEditorActive) { var msgCfg = { callback: that, element: that._newMessageInlineElement, op: "__Send", baseURL: that._config.containerBaseUrl, objType: FIRSTCLASS.objTypes.message, formID: 21001, formElId: "fcDocForm", bodyType: "HTML", quoteText: null, sendTo: null, initHeight: "240px", showAddr: false, tbType: "message", params: "InitialText=", dataSource: that._dataSource, maxImage: 480, callback: { onFail: function() { that.clearEditorActive(); if (that._msgEditor && that._msgEditor !== null) { that._msgEditor.destroy(); that._msgEditor = null; } that._newMessageInlineElement.innerHTML = ""; }, onSave: function() { that.clearEditorActive(); if (that._msgEditor && that._msgEditor !== null) { that._msgEditor.destroy(); that._msgEditor = null; } that._newMessageInlineElement.innerHTML = ""; }, onCancel: function() { that.clearEditorActive(); if (that._msgEditor && that._msgEditor !== null) { that._msgEditor.destroy(); that._msgEditor = null; } that._newMessageInlineElement.innerHTML = ""; } } }; that._msgEditor = new FIRSTCLASS.util.Message(msgCfg); if (that._msgEditor !== null) { that.setEditorActive(); that._listView.clearSelection(); } } }, upload: function(that, fcevent) { if (!FIRSTCLASS.apps.Workflows.uploadDocument._isOpen) { var uploadConfig = { ds: that._dataSource, dsr: null, paneEl: that._domElement }; var workflow = new FIRSTCLASS.apps.Workflows.uploadDocument(uploadConfig); } }, about: function(that, fcevent) { var workflow = new FIRSTCLASS.apps.Workflows.AboutCommunity( { baseUrl: FIRSTCLASS.session.getActiveObject(), title: that._config.community._title, acl: that._config.community._config.acl, icon: that._config.community._config.params.icon, isalias: that._config.community._config.isalias }); }, feeds: function(that, fcevent) { var el = $("fcFeedContainerWatch" + that._instance); if (that._config.watched) { FIRSTCLASS.session.desktop.stopContainerBeingWatched(that._config.containerBaseUrl); } else { YAHOO.util.Connect.asyncRequest('GET', that._config.containerBaseUrl + "?Watch=1"); } FIRSTCLASS.session.desktop._dataSource.fetchRows(false, false, false, false, true); that._config.watched = !that._config.watched; el.innerHTML = (that._config.watched ? FIRSTCLASS.locale.community.feed.actions.unwatch : FIRSTCLASS.locale.community.feed.actions.watch); }, removename: function(that, fcevent) { FIRSTCLASS.util.Form.deleteName(that._config.containerBaseUrl + "/__ListSubscribers", 11, false, parseInt(fcevent.fcattrs)); }, unread: function(that, fcevent) { that.eventHandlers.click.clearunread(that, fcevent); }, acceptmember: function(that, fcevent) { if (FIRSTCLASS.permissions.hasPriv(that._config.community._config.acl, FIRSTCLASS.permissions.ACL.MODERATOR) == FIRSTCLASS.permissions.ACL.MODERATOR) { that.acceptMemberRequestStep1(fcevent); /* var formcontainer = document.createElement("div"); var uri = FIRSTCLASS.session.baseURL + "__MemForm/"+FIRSTCLASS.opCodes.FormEdit+ "/"+FIRSTCLASS.opCodes.FormSave+"?FormID=11215&Clear=0&Templates=Members"; var html = ["
"]; html.push(""); html.push(""); html.push("
"); formcontainer.innerHTML = html.join(""); FIRSTCLASS.util.submitForm(formcontainer.firstChild); fcevent.target.innerHTML = "member accepted, invitation sent"; fcevent.target.setAttribute('fcid',''); that._dataSource.updateFieldData(that._myFeed._selectedRow, [{id:5, type:"SHORT", value:23012}]);*/ } else { fcevent.target.innerHTML = FIRSTCLASS.locale.workflows.acceptmember.insufficientprivs; fcevent.target.setAttribute('fcid', ''); } }, reset: function(that, fcevent) { that._filterThread = false; that.__filteringByThread = false; that._dataSource.fetchRows(); that._listView.updateConfigParams({ fillOnScroll: true }); that._listView.reLoadFromDataSource(); that._listView.activate(); that._listView.clearPadText(); FIRSTCLASS.session.addHistoryEntry(that._config.community.generateHistoryEntry("Feed", that)); }, memberlist: function(that, fcevent) { var edit = true; if (fcevent.fcattrs && fcevent.fcattrs == "noedit") { edit = false; } FIRSTCLASS.apps.Workflows.MemberList.doShow(that._config.containerBaseUrl, edit); }, members: function(that, fcevent) { that._config.community.loadMembersApp(); } } }; FIRSTCLASS.apps.Discussion.prototype.handleEvent = function(evt, fcevent) { var rv = this._listView.thandler.handleEvent(evt, fcevent); if (!rv) { if (this._config.community.membersApp && this._config.community.membersApp.isVisible()) { rv = this._config.community.membersApp.handleEvent(evt, fcevent); } if (!rv) { rv = this._myFeed.handleEvent(evt, fcevent); if (!rv) { var handlers = this.eventHandlers[evt.type]; if (handlers) { var handler = handlers[fcevent.fcid]; if (handler) { rv = handler(this, fcevent); if (typeof rv == "undefined") { rv = true; } } } } } } return rv; }; // class methods FIRSTCLASS.apps.Discussion.prototype.createRow = function(row) { var myRowContents = null; var myRowElement = null; var children = null; if (this._myFeed) { myRowContents = this._myFeed.createRow(row); } else { myRowContents = document.createElement("div"); } YAHOO.util.Dom.addClass(myRowContents, "fcDiscussionItem"); /*myRowElement = FIRSTCLASS.apps.Discussion.prototype._rowSubElement.cloneNode(true); var child = myRowElement.childNodes[0].childNodes[0].childNodes[0].childNodes[1]; // var child = FIRSTCLASS.ui.Dom.getChildByClassName("fcDiscussionItemCell", myRowElement); child.appendChild(myRowContents); myRowElement.row = myRowContents.row;*/ return myRowContents; }; FIRSTCLASS.apps.Discussion.prototype.updateRow = function(row, element, oldrow) { /*var myRowContents = FIRSTCLASS.ui.Dom.getChildByClassName("fcDiscussionItem", element); if (this._myFeed && (myRowContents)) { this._myFeed.updateRow(row,myRowContents); }*/ this._myFeed.updateRow(row,element, oldrow); }; FIRSTCLASS.apps.Discussion.prototype.onRowClick = function(row, elem) { this._myFeed.onRowClick(row, elem); }; FIRSTCLASS.apps.Discussion.prototype.generateUniqueId = function(row) { return row.messageid; }; FIRSTCLASS.apps.Discussion.prototype.onSelectionChange = function(from, to, torow) { return this._myFeed.onSelectionChange(from, to, torow); }; // sort thread items in reverse chrono FIRSTCLASS.apps.Discussion.prototype._rowSort = function(row1, row2) { var result = true; if (!row1.status.backversion && (row1.typedef.objtype == FIRSTCLASS.objTypes.fcfile || row1.typedef.objtype == FIRSTCLASS.objTypes.file || row1.typedef.objtype == FIRSTCLASS.objTypes.odocument)) { return -1; } else if (!row2.status.backversion && (row2.typedef.objtype == FIRSTCLASS.objTypes.fcfile || row2.typedef.objtype == FIRSTCLASS.objTypes.file || row2.typedef.objtype == FIRSTCLASS.objTypes.odocument)) { return 1; } if (row1.col8090 && row2.col8090 && (row1.typedef.objtype == FIRSTCLASS.objTypes.fcfile || row1.typedef.objtype == FIRSTCLASS.objTypes.file || row1.typedef.objtype == FIRSTCLASS.objTypes.odocument) && (row2.typedef.objtype == FIRSTCLASS.objTypes.fcfile || row2.typedef.objtype == FIRSTCLASS.objTypes.file || row2.typedef.objtype == FIRSTCLASS.objTypes.odocument)) { //return row1.col8090 < row2.col8090; if (row1.col8090 < row2.col8090) { return -1; } else if (row1.col8090 == row2.col8090) { return 0; } else { return 1; } } /*if (row1 && row2) { result = row1.parsedDate >= row2.parsedDate; }*/ if (row1.parsedDate < row2.parsedDate) { return -1; } else if (row1.parsedDate == row2.parsedDate) { return 0; } else { return 1; } return result; }; FIRSTCLASS.apps.Discussion.prototype.rowSort = function(row1, row2) { /* var result = true; if (row1 && row2) { result = row1.parsedDate <= row2.parsedDate; }*/ if (row1 && row2) { if (row1.parsedDate < row2.parsedDate) { return 1; } else if (row1.parsedDate == row2.parsedDate) { return 0; } else { return -1; } } return 1; // return result; }; FIRSTCLASS.apps.Discussion.prototype.activate = function () { this._isActive = true; this._listView.activate(); this._dataSource.activate(); FIRSTCLASS.ui.rightSideBar.updateBoxContents(FIRSTCLASS.locale.community.actions.lbl, this._appTBElement); if (this._config.onResize) { this._config.onResize(); } if (YAHOO.env.ua.ie < 8) { document.body.setAttribute('scroll','no'); } FIRSTCLASS.session.setActiveApplication(this, "discussion"); }; FIRSTCLASS.apps.Discussion.prototype.deactivate = function(internal) { this._isActive = false; this._listView.deactivate(); // this._dataSource.deactivate(); }; FIRSTCLASS.apps.Discussion.prototype.getRowFilter = function() { var that = this; return function(row, isNewDelivery) { if (that._filterThread) { return row.threadid == that._filterThread; } else { if (typeof that._isActive != "undefined" && !that._isActive && !isNewDelivery) { return false; } if (row.status.deleted == 1) { return false; } if ((row.typedef.objtype == FIRSTCLASS.objTypes.odocument) && !row.col8082) { return false; } return row.typedef.isleaf; } }; }; FIRSTCLASS.apps.Discussion.prototype.onListViewFillFinished = function() { /* if (this._filteringByThread && !this._hasBeenScrolled) { this._listView.selectRow(this._filterRow, true, true); this._hasBeenScrolled = true; }*/ }; FIRSTCLASS.apps.Discussion.prototype.setShowRowInContextPadText = function() { this._listView.updatePadText("

" + FIRSTCLASS.locale.community.feed.threadonly + "

", true); }; FIRSTCLASS.apps.Discussion.prototype.showRowInContext = function(row, oncomplete) { this._filterThread = row.threadid; this._filterRow = row; this._filteringByThread = true; this._listView.updateConfigParams({ fillOnScroll: false }); this._listView.reLoadFromDataSource(); this._listView.selectRow(row, false, true); this.setShowRowInContextPadText(); FIRSTCLASS.session.addHistoryEntry(this._config.community.generateHistoryEntry("Feed", this, row, true)); if (oncomplete) { oncomplete(); } }; FIRSTCLASS.apps.Discussion.prototype.onCancel = function() { this._newMessageInlineElement.innerHTML = ""; var Y = YAHOO.util.Dom.getY(this._lvDomElement); var ht = YAHOO.util.Dom.getViewportHeight(); YAHOO.util.Dom.setStyle(this._lvDomElement, 'height', ht-Y + "px"); }; FIRSTCLASS.apps.Discussion.prototype.onSave = function() { this.onCancel(); }; YAHOO.register("fcDiscussion", FIRSTCLASS.apps.Discussion, {version: "0.0.1", build: "1"});