/** * 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 = "