/** * 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.AppTemplate = function(config) { /** * Private member variables * * Private variables are identified by the convention of naming them with a leading underscore. * i.e. this._privateVariable */ if (config.logTime) { config.logTime("Messaging App Init"); } var that = this; this._domElement = document.createElement("div"); this._config = config; var dsconfig = { containerBaseUrl: this.uri, autoLoad: false, watchForNew: true, messagebodies: false, nosymbiomainfetch: true, sortFirstFetch: false, serversort: "&Table=-3_9", fetchThreads: true, initialRequestGranularity: 5, requestGranularity: 10, pollInterval: 100, objtypefilter: FIRSTCLASS.objTypes.message }; if (this._config.logTime) { dsconfig.logTime = this._config.logTime; } this._dataSource = new FIRSTCLASS.util.DataSource(dsconfig); /*this.app = this;*/ /* set up the listview */ 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, "fcMailbox"); this._contentPane = FIRSTCLASS.ui.widgets.buildContentBox(this._lvDomElement, 'fcWhiteContentBox'); this._domElement.appendChild(this._contentPane); var lvConfig = { domElement: this._lvDomElement, dataSource: this._dataSource, fillOnScroll:true, threading: { format: "bythread", sortfunc: this._rowSort, threadsortfunc: this._threadSort, originRowIsHeader: true, collapseRead: true, displayThreadContributors: true }, listenForNavKeys: false, selectionFollowsScroll: true, padHeight: true, padText: FIRSTCLASS.locale.community.loading, drawOffScreen: false, rowFilter: this.rowFilter, feedConfig: { inlineReplyIcon: 150, inlineReplyFormID: 21007, replyMode: "All" } }; this._listView = new FIRSTCLASS.layout.ListView(lvConfig); this._dataSource.addRowListener(this); FIRSTCLASS.session.addHistoryEntry(this); this.activate(); }; /** HISTORY MANAGEMENT VARIABLES **/ FIRSTCLASS.apps.AppTemplate.prototype.uri = FIRSTCLASS.session.baseURL + "__Open-Item/Mailbox"; FIRSTCLASS.apps.AppTemplate.prototype.cacheable = false; /** HISTORY MANAGEMENT VARIABLES END **/ FIRSTCLASS.apps.AppTemplate.prototype.onRow = function(row, dataSource, atEnd, hasMore, isNewDelivery) { if (isNewDelivery) { this._listView.selectRow(row); } }; FIRSTCLASS.apps.AppTemplate.prototype.rowFilter = function(row) { return row.status.sent && row.status.outgoing || !row.status.outgoing; }; FIRSTCLASS.apps.AppTemplate.prototype.activate = function () { this.activateSideBars(); FIRSTCLASS.util.revealContents(); FIRSTCLASS.ui.Dom.replaceContentsWithElement(this._config.parentDiv, this._domElement); this.resizeEvent(); FIRSTCLASS.session.setActiveApplication(this, "AppTemplate"); YAHOO.util.Dom.setStyle(document.body, "height", "100%"); YAHOO.util.Dom.setStyle(document.body, "overflow", "hidden"); }; FIRSTCLASS.apps.AppTemplate.prototype.__fcAppName = "FIRSTCLASS.apps.AppTemplate"; FIRSTCLASS.apps.AppTemplate.prototype.deactivate = function() { FIRSTCLASS.ui.MiniProfile.hideBoxNow(); YAHOO.util.Dom.setStyle(document.body, "height", ""); YAHOO.util.Dom.setStyle(document.body, "overflow", ""); // this._dataSource.deactivate(); }; FIRSTCLASS.apps.AppTemplate.prototype.dispose = function() { if (this._config.logTime) { this._config.logTime("AppTemplate app dispose called"); } // this._dataSource.dispose(); }; FIRSTCLASS.apps.AppTemplate.prototype.activateSideBars = function() { FIRSTCLASS.ui.leftSideBar.hide(); FIRSTCLASS.ui.rightSideBar.show(); FIRSTCLASS.ui.rightSideBar.resetApplicationBoxContents(); }; FIRSTCLASS.apps.AppTemplate.prototype.resizeEvent = function(event) { 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 = 115; 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*.02; if (sbwid < 180) { sbwid = 180; } FIRSTCLASS.session.RuntimeCSS.updateRule('.fcListViewRow .fcBody', "max-width: " + (viewport.wd - sbwid - 300) + "px;overflow-x:auto;"); var newheight = viewport.ht-ypos-1; if (ypos) { var appContent = FIRSTCLASS.ui.Dom.getChildByClassName("fcAppScrollingContent", this._domElement); if (appContent) { 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"); } } var fcMain = $("fcMain"); if (fcMain) { YAHOO.util.Dom.setStyle(fcMain, "height", viewport.ht+"px"); } }; FIRSTCLASS.apps.AppTemplate.prototype.eventHandlers = { click: { template: function(evt, fcevent) { } } }; FIRSTCLASS.apps.AppTemplate.prototype.handleEvent = function(evt, fcevent) { var rv = false; 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; }; YAHOO.register("fcMessaging", FIRSTCLASS.apps.AppTemplate, {version: "0.0.1", build: "1"});