/** * 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++; FIRSTCLASS.session.debug.writeMessage({"1":"Community App Init", "10":this}); this._subApps = [ {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"} ]; 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", 80); this._iconuri = config.params.icon; FIRSTCLASS.ui.navBar.setProfileUnread(this._unread); 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"); FIRSTCLASS.session.debug.writeMessage({"module": "FIRSTCLASS.apps.Community", "1": {'message': "activetabchange called", 'oldtab':oldTab, 'newtab':newTab}}); var oldTabDomElem = evt.prevValue.get("contentEl"); var newTabDomElem = evt.newValue.get("contentEl"); var newTabID = ""; var reset = false; for (var i = 0; i < that._subApps.length; i++) { if ((oldTab !== newTab) || (that._subApps[i].app === "fcDiscussion")) { 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; } reset = true; } } if (newTabID !== "") { that.loadApplication(newTabID, true, false, that._showoncomplete, reset); } that._showoncomplete = false; //that.resizeEvent(); }); this._tabView.addListener('beforeActiveTabChange', function(evt) { FIRSTCLASS.ui.ToolbarPopup.closePopup(); 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 = { name: "Feed", containerBaseUrl: this._config.baseUrl, autoLoad: false, watchForNew: true, messagebodies: false, nosymbiomainfetch: true, sortFirstFetch: false, serversort: "&Table=-3_9", fetchThreads: true, initialRequestGranularity: 5, requestGranularity: 10, pollInterval: 1000 }; 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 && FIRSTCLASS.appProperties.sounds.supported && FIRSTCLASS.appProperties.sounds.community.newitem) { 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) { var str, title, subheader, cloud; switch (data) { case "name": if (!that._title) { FIRSTCLASS.ui.setDocumentTitle(contents); that._title = contents; 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'); FIRSTCLASS.ui.leftSideBar.updateBoxAction(FIRSTCLASS.locale.community.members.lbl, false, false, 'members'); that._aclConfigured = true; that._config.acl = contents; }*/ if (FIRSTCLASS.permissions.hasPriv(contents, FIRSTCLASS.permissions.ACL.CRTCONF) == FIRSTCLASS.permissions.ACL.CRTCONF) { that._createsubcommunities = true; FIRSTCLASS.ui.rightSideBar.updateBoxAction(FIRSTCLASS.locale.desktop.communities, false, false, 'subcommunity'); FIRSTCLASS.ui.leftSideBar.updateBoxAction(FIRSTCLASS.locale.desktop.communities, false, false, 'subcommunity'); } 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); FIRSTCLASS.ui.leftSideBar.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; that._createsubcommunities = true; //FIRSTCLASS.ui.rightSideBar.updateBoxAction(FIRSTCLASS.locale.community.members.lbl, false, false, 'members'); //FIRSTCLASS.ui.leftSideBar.updateBoxAction(FIRSTCLASS.locale.community.members.lbl, false, false, 'members'); FIRSTCLASS.ui.rightSideBar.updateBoxAction(FIRSTCLASS.locale.desktop.communities, false, false, 'subcommunity'); FIRSTCLASS.ui.leftSideBar.updateBoxAction(FIRSTCLASS.locale.desktop.communities, false, false, 'subcommunity'); // 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) { 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 ((true || that.applyIconAsProfilePicture) && that.applyIconAsProfilePicture != 2) { FIRSTCLASS.ui.navBar.setProfilePicture(contents.uri, false, "about", 80); 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; str = ""; if (that._alias) { str = "" + FIRSTCLASS.lang.mlesc(that._alias) + " "; } str = str + "(" + (parseInt(that._stats.lConfSubscribers) + 1) + " " + 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; 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; break; case "layout": if (that._layout != contents) { that._layout = contents; that.layoutSideBar(); this._reloadSideBars = true; } break; case "hasembed": if (that._hasembed != contents) { that._hasembed = contents; that.layoutSideBar(); this._reloadSideBars = true; } break; case "embedcode": if (that._embedcode != contents) { that._embedcode = contents; that.layoutSideBar(); this._reloadSideBars = true; } break; default: } }, onHeaderDataFinished: function() { if (false && this._reloadSideBars) { that.layoutSideBar(); this._reloadSideBars = false; } }, filter: function(dataname) { var rc = false; switch (dataname) { case "name": case "icon": case "tags": case "objid": case "skin": case "alias": case "stats": case "folderid": case "layout": case "hasembed": case "embedcode": rc = true; break; case "acl": if (!that._aclConfigured) { rc = true; } break; case "typedef": if (!that._typedefConfigured) { rc = true; } break; default: rc = false; } return rc; } }); 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.eventHandlers = { click: { uncollapsebox: function(that, fcevent) { that.showApplicationBox(fcevent.fcattrs); }, collapsebox: function(that, fcevent) { that.hideApplicationBox(fcevent.fcattrs); }, memberlist: function(that, fcevent) { var edit = FIRSTCLASS.permissions.hasPriv(that._dataSource._data.acl, FIRSTCLASS.permissions.ACL.EDITACL); var external = false; if (fcevent.fcattrs && fcevent.fcattrs.indexOf("external") >= 0) { external = true; } var creatorcid = that._dataSource._data.creatorcid; FIRSTCLASS.apps.Workflows.MemberList.doShow(that._config.baseUrl, edit, external, creatorcid); }, members: function(that, fcevent) { that.loadMembersApp(); }, subcommunity: function(that, fcevent) { FIRSTCLASS.loadApplication(FIRSTCLASS.session.baseURL, -103, 0, {root: that._config.baseUrl, datasource: that._dataSource}); }, subcommunitydelete: function(that, fcevent) { var uri = fcevent.fcattrs; var rows = that._dataSource.query("uri", FIRSTCLASS.lang.removeSlashUrl(uri), true, function(key, search) { var newkey = FIRSTCLASS.lang.removeSlashUrl(key); var newsearch = FIRSTCLASS.lang.removeSlashUrl(search); return (newkey.indexOf(newsearch) >= 0); }); if (rows.length > 0) { var answer = false; if(!rows[0][1].status.alias) { answer=confirm(FIRSTCLASS.locale.desktop.delconfirm); } else { var question = FIRSTCLASS.locale.desktop.unsubconfirm[rows[0][1].typedef.subtype]; if (question) { answer=confirm(question); } else { answer = true; } } if (answer) { that._dataSource.deleteRow(rows[0][1]); } } }, docimportfromrepo: function(that, fcevent) { var repositoryname = fcevent.fcattrs; var repository = FIRSTCLASS.apps.Integration.getRepositoryByName(repositoryname); FIRSTCLASS.apps.Integration.ECM.Browse.doBrowse({'xuid':2000, 'title':'Browse ' + repositoryname, showleaves: true, callbacks: {save: FIRSTCLASS.apps.Integration.ECM.Browse.Actions.copy}, repository:repositoryname, target: that._config.params.lconfcid, selMode: 1}); } } }; FIRSTCLASS.apps.Community.prototype.handleEvent = function(evt, fcevent) { var rv = false; if (this.membersApp && this.membersApp.isVisible()) { rv = this.membersApp.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; }; 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, false, "about", 80); } if (this._skin) { FIRSTCLASS.ui.skin.set(this._skin); } FIRSTCLASS.ui.setPageRSSFeed({href: FIRSTCLASS.lang.ensureSlashUrl(FIRSTCLASS.session.baseURL) + this._config.baseUrl + "?Plugin=RSS&Leaves=0-100", title: this._title}); }; 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); } } FIRSTCLASS.ui.clearPageRSSFeed(); } 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(this._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() { if (instance && instance.activate) { instance.activate(); } else { that.activate(); } that._tabView.set("activeTab", that._tabs[tabName]); }, deactivate:function() { if (instance && instance.deactivate) { instance.deactivate(that.isSwitchingToSubApp()); } else { 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, reset) { if (typeof reset == "undefined") { reset = true; } 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 = this.getSuccessFunction({tabName:tabName, tab:tab, index:j, activate: activate, rowToOpen: rowToOpen, showoncomplete: showoncomplete, reset: reset}); FIRSTCLASS._loader.insert(); return; } } }; FIRSTCLASS.apps.Community.prototype.getSuccessFunction = function(cfg) { var tabName = cfg.tabName, tab = cfg.tab, j = cfg.index, activate = cfg.activate, rowToOpen = cfg.rowToOpen, that = this, reset = cfg.reset, showoncomplete = cfg.showoncomplete; var func = function(o) { if (that._config.logTime) { that._config.logTime("Community loadApplication finished: " + tabName); } var app = that._subApps[j]; var created = false; var activateparams = {reset: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; } } else { activateparams.reset = reset; } 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(activateparams); 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(); } } }; return func; }; 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; var bottompad = 0; if (FIRSTCLASS.skin && FIRSTCLASS.skin.community && FIRSTCLASS.skin.community.sidebars && FIRSTCLASS.skin.community.sidebars.right && FIRSTCLASS.skin.community.sidebars.right.bottompad) { bottompad = FIRSTCLASS.skin.community.sidebars.right.bottompad; } if (this._layoutskin && this._layoutskin.community && this._layoutskin.community.sidebars && this._layoutskin.community.sidebars.right && this._layoutskin.community.sidebars.right.bottompad) { bottompad = this._layoutskin.community.sidebars.right.bottompad; } var sbtopr = sbTop + bottompad; bottompad = 0; if (FIRSTCLASS.skin && FIRSTCLASS.skin.community && FIRSTCLASS.skin.community.sidebars && FIRSTCLASS.skin.community.sidebars.left && FIRSTCLASS.skin.community.sidebars.left.bottompad) { bottompad = FIRSTCLASS.skin.community.sidebars.left.bottompad; } if (this._layoutskin && this._layoutskin.community && this._layoutskin.community.sidebars && this._layoutskin.community.sidebars.left && this._layoutskin.community.sidebars.left.bottompad) { bottompad = this._layoutskin.community.sidebars.left.bottompad; } var sbtopl = sbTop + bottompad; FIRSTCLASS.ui.rightSideBar.adjustBoxHeights(viewport.ht-sbtopr); FIRSTCLASS.ui.leftSideBar.adjustBoxHeights(viewport.ht-sbtopl); var sbwid = viewport.wd*0.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) { var tab = this._tabView.get('activeTab'); var tabcont = tab.get('contentEl'); var newheight = viewport.ht-ypos-1, newwidth; if (ypos) { var appContent = FIRSTCLASS.ui.Dom.getChildByClassName("fcAppScrollingContent", tabcont); if (appContent) { newheight = viewport.ht - ypos2 - 1; if (newheight <= 0) { return; } 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"); } else { var tabContent = FIRSTCLASS.ui.Dom.getChildByClassName("fcContentWrapper", tabcont); if (tabContent) { newheight = viewport.ht - ypos2 - 1; if (newheight <= 0) { return; } newwidth = viewport.wd - xpos2 - 1; YAHOO.util.Dom.setStyle(tabContent, "overflow", "auto"); YAHOO.util.Dom.setStyle(tabContent, "height", newheight+"px"); } else { if (newheight <= 0) { return; } } } 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( { name: "MemberList", 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; } }); 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'); 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, 10) + (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, 10) + (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._createsubcommunities != "undefined"; }, false, function(bdelete, row) { bdelete.setAttribute('fcid', 'removename'); bdelete.setAttribute('fcattrs', row.uid); } ) }; this._memberlistlv = new FIRSTCLASS.layout.ListView(memberlistcfg); this._communitylist = document.createElement("div"); var communitylistcfg = { domElement: this._communitylist, dataSource: this._dataSource, threading: { format: FIRSTCLASS.layout.ThreadHandler.types.NONE }, compareRows:function(row1,row2) { }, rowFilter: function(row){ return row.typedef.isleaf === 0; }, keepRowsSorted: false, rowHandler: new FIRSTCLASS.layout.CommunityListHandler( that._dataSource, function() { return false; }, true, function(bdelete, row) { bdelete.setAttribute('fcid', 'removename'); bdelete.setAttribute('fcattrs', row.uid); } ) }; this._communitylistlv = new FIRSTCLASS.layout.ListView(communitylistcfg); 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.maxHeight = 200; } this.layoutSideBar(); }; FIRSTCLASS.apps.Community.prototype.layoutSideBar = function() { var skin = { community: { sidebars: { right: { bottompad: 60, visible: true, contents: [ { id: "userembed", type:"embed", url: FIRSTCLASS.lang.ensureSlashUrl(this._config.baseUrl) + "__Resume?Templates=Embed&FormID=97&Quit=1", css: "width:440px;height:345px;border:0px;overflow:hidden;", title: "", hidden: true }, {id: "actions"}, { id: "communityinfo", collapsed: true, collapsible: true, type:"embed", url: FIRSTCLASS.lang.ensureSlashUrl(this._config.baseUrl) + "?Templates=Stubs&FormID=101", title: FIRSTCLASS.locale.community.communityinfo.lbl, hidden: false, issafe: true }, {id: "members", collapsible: true}, {id: "communities"}, {id: "tags", collapsible: true} ] }, left: { bottompad: 60, visible: false, contents: [] } } } }, i, r, contents; if (FIRSTCLASS.skin && FIRSTCLASS.skin.community && FIRSTCLASS.skin.community.sidebars) { if (FIRSTCLASS.skin.community.sidebars.left) { skin.sidebars.left = FIRSTCLASS.skin.community.sidebars.left; } if (FIRSTCLASS.skin.community.sidebars.right) { skin.sidebars.right = FIRSTCLASS.skin.community.sidebars.right; } } if (this._layout) { /* */ switch (this._layout) { case 1: skin = { community: { sidebars: { left: { bottompad: 60, visible: true, contents: [ { id: "userembed", type:"embed", url: FIRSTCLASS.lang.ensureSlashUrl(this._config.baseUrl) + "__Resume?Templates=Embed&FormID=97&Quit=1", css: "width:440px;height:360px;border:0px;", title: "", hidden: true }, {id: "actions"}, { id: "communityinfo", collapsed: true, collapsible: true, type:"embed", url: FIRSTCLASS.lang.ensureSlashUrl(this._config.baseUrl) + "?Templates=Stubs&FormID=101", title: FIRSTCLASS.locale.community.feed.abouttitle.toUpperCase().replace(":",""), hidden: false, issafe: true }, {id: "members"}, {id: "communities"}, {id: "tags"} ] }, right: { visible: false, contents: [] } } } }; break; case 2: skin = { community: { sidebars: { right: { bottompad: 60, visible: true, contents: [ { id: "userembed", type:"embed", url: FIRSTCLASS.lang.ensureSlashUrl(this._config.baseUrl) + "__Resume?Templates=Embed&FormID=97&Quit=1", css: "width:440px;height:360px;border:0px;", title: "", hidden: true }, {id: "actions"}, { id: "communityinfo", collapsed: true, collapsible: true, type:"embed", url: FIRSTCLASS.lang.ensureSlashUrl(this._config.baseUrl) + "?Templates=Stubs&FormID=101", title: FIRSTCLASS.locale.community.feed.abouttitle.toUpperCase().replace(":",""), hidden: false, issafe: true }, {id: "communities"}, {id: "members"} ] }, left: { visible: false, contents: [] } } } }; break; case 3: skin = { community: { sidebars: { left: { bottompad: 60, visible: true, contents: [ { id: "userembed", type:"embed", url: FIRSTCLASS.lang.ensureSlashUrl(this._config.baseUrl) + "__Resume?Templates=Embed&FormID=97&Quit=1", css: "width:440px;height:360px;border:0px;", title: "", hidden: true }, {id: "actions"}, { id: "communityinfo", collapsed: true, collapsible: true, type:"embed", url: FIRSTCLASS.lang.ensureSlashUrl(this._config.baseUrl) + "?Templates=Stubs&FormID=101", title: FIRSTCLASS.locale.community.feed.abouttitle.toUpperCase().replace(":",""), hidden: false, issafe: true }, {id: "communities"}, {id: "members"} ] }, right: { visible: false, contents: [] } } } }; break; case 4: skin = { community: { sidebars: { right: { bottompad: 80, visible: true, contents: [ {id: "actions"}, {id: "communities"}, {id: "members"} ] }, left: { bottompad: 80, visible: true, contents: [ { id: "userembed", type:"embed", url: FIRSTCLASS.lang.ensureSlashUrl(this._config.baseUrl) + "__Resume?Templates=Embed&FormID=97&Quit=1", css: "width:440px;height:360px;border:0px;", title: "", hidden: true }, { id: "communityinfo", collapsed: true, collapsible: true, type:"embed", url: FIRSTCLASS.lang.ensureSlashUrl(this._config.baseUrl) + "?Templates=Stubs&FormID=101", title: FIRSTCLASS.locale.community.feed.abouttitle.toUpperCase().replace(":",""), hidden: false, issafe: true }, {id: "tags"} ] } } } }; break; } } this._layoutskin = skin; if (this._hasembed) { for (i in skin.community.sidebars.left.contents) { r = skin.community.sidebars.left.contents[i]; if (r.type == "embed" && r.id == "userembed") { r.hidden = false; } } for (i in skin.community.sidebars.right.contents) { r = skin.community.sidebars.right.contents[i]; if (r.type == "embed" && r.id == "userembed") { r.hidden = false; } } } FIRSTCLASS.ui.leftSideBar.resetApplicationBoxContents(); if (skin.community.sidebars.left.visible) { FIRSTCLASS.ui.leftSideBar.show(); contents = skin.community.sidebars.left.contents; for (i in contents) { if (!contents[i].hidden) { this.buildApplicationBox(FIRSTCLASS.ui.leftSideBar, contents[i]); } } } else { FIRSTCLASS.ui.leftSideBar.hide(); } FIRSTCLASS.ui.rightSideBar.resetApplicationBoxContents(); if (skin.community.sidebars.right.visible) { FIRSTCLASS.ui.rightSideBar.show(); contents = skin.community.sidebars.right.contents; for (i in contents) { if (!contents[i].hidden) { this.buildApplicationBox(FIRSTCLASS.ui.rightSideBar, contents[i]); } } } else { FIRSTCLASS.ui.rightSideBar.hide(); } this.resizeEvent(); }; FIRSTCLASS.apps.Community.prototype.loadMembersApp = function() { var domElem = document.createElement("div"); var burl = FIRSTCLASS.lang.ensureSlashUrl(FIRSTCLASS.session.baseURL) + "__MemForm/"+FIRSTCLASS.opCodes.FormSave; if (this.membersApp) { this.membersApp.close(); this.membersApp = false; } 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(); } } }; /* CRAP FOR RFP */ FIRSTCLASS.apps.Community.applicationBoxCallbacks = { success: function(o) { this.boxinfo.html = o.responseText; this.boxinfo.div.innerHTML = o.responseText; this.community.resizeEvent(false, false); }, failure: function(o) { this.boxinfo.html = o.responseText; this.boxinfo.div.innerHTML = o.responseText; this.community.resizeEvent(false, false); } }; FIRSTCLASS.apps.Community.prototype.getApplicationBox = function(boxname) { var skin = this._layoutskin; var boxinfo = false; var sidebar = false; if (skin.community.sidebars.left.visible) { contents = skin.community.sidebars.left.contents; for (i in contents) { if (!contents[i].hidden) { var tbox = contents[i]; if (tbox.title == boxname) { sidebar = FIRSTCLASS.ui.leftSideBar; boxinfo = tbox; break; } } } } if (skin.community.sidebars.right.visible && !boxinfo) { contents = skin.community.sidebars.right.contents; for (i in contents) { if (!contents[i].hidden) { var tbox = contents[i]; if (tbox.title == boxname) { boxinfo = tbox; sidebar = FIRSTCLASS.ui.rightSideBar; break; } } } } return {sidebar: sidebar, boxinfo: boxinfo}; }; FIRSTCLASS.apps.Community.prototype.showApplicationBox = function(boxname) { var box = this.getApplicationBox(boxname); var boxinfo = box.boxinfo; FIRSTCLASS.apps.Community.applicationBoxCallbacks.boxinfo = boxinfo; FIRSTCLASS.apps.Community.applicationBoxCallbacks.community = this; boxinfo.collapsed = false; boxinfo.div.collapsed = false; YAHOO.util.Dom.setStyle(boxinfo.div, "height", ""); if (boxinfo.html) { boxinfo.div.innerHTML = boxinfo.html; } else if (boxinfo.hiddencontents) { FIRSTCLASS.ui.Dom.replaceChildrenWithChildren(boxinfo.div, boxinfo.hiddencontents); } else { boxinfo.div.innerHTML = "
"; this.resizeEvent(false, false); FIRSTCLASS.util.net.doAsyncGet({action:boxinfo.url, callbacks:FIRSTCLASS.apps.Community.applicationBoxCallbacks}); } boxinfo.div.collapsed = false; this.resizeEvent(false, false); box.sidebar.updateBoxAction(boxname, "collapsebox", FIRSTCLASS.locale.community.hide, 'collapsebox'); }; FIRSTCLASS.apps.Community.prototype.hideApplicationBox = function(boxname) { var box = this.getApplicationBox(boxname); var boxinfo = box.boxinfo; boxinfo.hiddencontents = document.createElement("div"); FIRSTCLASS.ui.Dom.replaceChildrenWithChildren(boxinfo.hiddencontents, boxinfo.div); boxinfo.collapsed = true; boxinfo.div.collapsed = true; box.sidebar.updateBoxAction(boxname, "uncollapsebox", FIRSTCLASS.locale.community.show, 'uncollapsebox'); this.resizeEvent(false, false); }; FIRSTCLASS.apps.Community.prototype.buildApplicationBox = function(sidebar, boxinfo) { var title = false; var div = false; if (boxinfo.type === "embed") { boxinfo.div = document.createElement("div"); div = boxinfo.div; title = boxinfo.title; sidebar.addApplicationBox(boxinfo.div, title); /* if (boxinfo.collapsed) { sidebar.updateBoxAction(title, "uncollapsebox", FIRSTCLASS.locale.community.show, 'uncollapsebox'); } else if (boxinfo.collapsible) { sidebar.updateBoxAction(title, "collapsebox", FIRSTCLASS.locale.community.hide, 'collapsebox'); }*/ if (boxinfo.html) { boxinfo.div.innerHTML = boxinfo.html; } else if (boxinfo.url) { if (this._embedcode && this._embedcode != "") { boxinfo.div.innerHTML = this._embedcode;//"