/** * Search.js - implements the Search application top view * mar.08 - items only - need to add page view, toolbar, etc. **/ FIRSTCLASS.apps.Search = function(config) { FIRSTCLASS.util.revealContents(); var that = this; this._domElement = null; this._dataSource = null; this.fcAppName = "fcSearch"; this._config = config; this._config.onready(); this._domElement = this._config.div; this._parentDiv = config.parentDiv; this._rowsPerPage = 10; this._integrations = {}; var canhavetabs = true; if (typeof config.params.mode != "undefined" && config.params.mode > 0) { canhavetabs = false; } var domElem = this._domElement; var hastabs = false; if (canhavetabs) { var doTabInit = function() { var repositories = FIRSTCLASS.apps.Integration.getRepositories(); if (repositories.length > 0) { var newDomElem = FIRSTCLASS.ui.Dom.clearElementChildren(that._domElement); that._tabs = {}; that._tabView = new YAHOO.widget.TabView(); that._tabs[FIRSTCLASS.session.serverName] = new YAHOO.widget.Tab({label: FIRSTCLASS.session.serverName, active:true}); that._tabView.addTab(that._tabs[FIRSTCLASS.session.serverName]); for (var i in FIRSTCLASS.apps.Integration.getRepositories()) { var repository = repositories[i]; if (repository.capabilities.search) { that._tabs[repository.name] = new YAHOO.widget.Tab({label: repository.name, active:false}); that._tabView.addTab(that._tabs[repository.name]); } } that._tabView.appendTo(that._domElement); that._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"); YAHOO.util.Dom.setStyle(oldTabDomElem, 'display', 'none'); YAHOO.util.Dom.setStyle(newTabDomElem, 'display', ''); if (that._integrations[newTab]) { that._integrations[newTab].fetchRows(); } else if (/*FIRSTCLASS.session.ui.experimental &&*/ (typeof config.params.mode == "undefined" || config.params.mode === 0)) { for (var i in repositories) { var repository = repositories[i]; if (typeof that._integrations[newTab] == "undefined") { if (repository.name.indexOf(newTab) === 0 && newTab.indexOf(repository.name) === 0) { var ecmtab = that._tabs[newTab].get("contentEl"); var ecmdomel = document.createElement("div"); var box = FIRSTCLASS.ui.widgets.buildContentPane(ecmdomel, "fcTabContentPane"); YAHOO.util.Dom.setStyle(ecmtab, 'padding-right', '20px'); ecmtab.appendChild(box); repository.handler.search({"repository": newTab, "key": that._config.params.key, "domElement": ecmdomel}); that._integrations[newTab] = repository.handler; } } } } }); var searchdomtab = that._tabs[FIRSTCLASS.session.serverName].get("contentEl"); searchdomtab.appendChild(newDomElem); domElem = newDomElem; var bx = FIRSTCLASS.ui.Dom.getChildByClassName('fcWhiteContentBox', newDomElem); if (bx) { FIRSTCLASS.ui.widgets.convertBoxToPane(bx, 'fcTabContentPane'); } } }; if (FIRSTCLASS.apps.Integration._isInitialized) { doTabInit(); if (FIRSTCLASS.apps.Integration.getRepositories().length > 0) { hastabs = true; } } else { FIRSTCLASS.apps.Integration._onInit.push({func: doTabInit, config:false}); FIRSTCLASS.apps.Integration.init(); } } var dscfg = { containerBaseUrl: config.baseUrl, autoLoad: false, requestGranularity: 50, messagebodies: false, docbodies: false, nosymbiomainfetch: true, useobjid: true, isSameRow: function(row1, row2) { return row1.uri == row2.uri; } }; if (config.params.sortbylastmod) { dscfg.serversort = "&Table=-3_0"; } else { dscfg.serversort = ""; } this._dataSource = new FIRSTCLASS.util.DataSource(dscfg); this._dataSource.addDataListener(this); this._dataSource.addRowListener({ onRow:function(row, dataSource) { that._config.onLoaded(); /* if (that._config.params.showoncomplete) { FIRSTCLASS.util.revealContents(); that._config.params.showoncomplete = false; }*/ }, onFillCompleted:function(row, dataSource) { that._config.onLoaded(); if (that.items && that.items.childNodes[1].childNodes.length === 0) { that._itemsListView.updatePadText(FIRSTCLASS.locale.integrations.ecm.search.noresult); } else if (that.items) { that._itemsListView.updatePadText(FIRSTCLASS.locale.community.nomore); } } }); if (typeof config.params.mode == "undefined" || config.params.mode === 0) { domElem.innerHTML = "" + "" + "
" + "
" + FIRSTCLASS.locale.search.items.lbl + "
" + "
" + FIRSTCLASS.locale.search.people.lbl + "
" + FIRSTCLASS.locale.search.places.lbl+"
" + "" + "
"; } else if (config.params.mode == 1) { domElem.innerHTML = "" + "" + "
" + "
" + FIRSTCLASS.locale.search.bloglbl + "
" + "
" + FIRSTCLASS.locale.search.commlbl + "
"; } else if (config.params.mode == 2) { /* communities */ domElem.innerHTML = "" + "" + "
" + "
"; } else if (config.params.mode == 3) { /* people */ domElem.innerHTML = "" + "" + "
" + "
" + "
" + "
"; } else if (config.params.mode == 4) { /* recent activity */ domElem.innerHTML = "" + "" + "
" + "
" + FIRSTCLASS.locale.search.items.lbl + "
" + "
" + FIRSTCLASS.locale.search.people.lbl + "
" + FIRSTCLASS.locale.search.places.lbl+"
" + "" + "
"; } else { alert("INVALID SEARCH MODE:" + config.params.mode); } this.items = FIRSTCLASS.ui.Dom.getChildByClassName('items', domElem); this.people = FIRSTCLASS.ui.Dom.getChildByClassName('people', domElem); this.communities = FIRSTCLASS.ui.Dom.getChildByClassName('communities', domElem); this.groups = FIRSTCLASS.ui.Dom.getChildByClassName('groups', domElem); var content = $("fcSearchContent"); var parent; var box; if (content) { parent = content.parentNode; if (hastabs) { box = FIRSTCLASS.ui.widgets.buildContentPane(content, "fcTabContentPane"); } else { box = FIRSTCLASS.ui.widgets.buildContentBox(content, "fcWhiteContentBox"); } parent.appendChild(box); var itemsLvConfig = { domElement: this.items, dataSource: this._dataSource, listenForNavKeys: true, fillOnScroll: true, scrollContainer: document.body.parentNode, loadByPage: false, padHeight: true, /*placeholderText: "", suppressCatchup: true,*/ threading: { format: "none", sortfunc: false }, rowFilter: function(row) { if (row.col8092 && row.col8092 !== 0 || (row.col8106 && row.col8106 == 196611)) { return false; } return row.icon.id != 11138 && row.typedef.objtype != FIRSTCLASS.objTypes.conference && row.name != "FCXResume" && row.name != "TestResume"; }, rowHandler: FIRSTCLASS.apps.Search.handlers.content }; if(config.onResize) { itemsLvConfig.onResize = config.onResize; } this._itemsListView = new FIRSTCLASS.layout.ListView(itemsLvConfig); this._itemsListView.updatePadHeight(FIRSTCLASS.ui.Dom.getViewportHeight()); } content = $("fcSearchPeople"); if (content) { parent = content.parentNode; box = FIRSTCLASS.ui.widgets.buildContentBox(content, "fcWhiteContentBox"); YAHOO.util.Dom.setStyle(box, "margin-bottom", "10px"); parent.appendChild(box); var peopleLvConfig = { domElement: this.people, dataSource: this._dataSource, listenForNavKeys: true, fillOnScroll: false, placeholderText: "", threading: { format: "none", sortfunc: false }, rowFilter: function(row) { if (row.col8108 && (row.col8108 == 1 || row.col8108 == 5)) { return true; } return false; /* if (row.col8092 && row.col8092 !== 0) { return false; } switch (row.icon.id) { case 11138: return row.status.view == 1; default: return false; }*/ }, rowHandler: FIRSTCLASS.apps.Search.handlers.people }; this._peopleListView = new FIRSTCLASS.layout.ListView(peopleLvConfig); } content = $("fcSearchCommunities"); if (content) { parent = content.parentNode; box = FIRSTCLASS.ui.widgets.buildContentBox(content, "fcWhiteContentBox"); if (typeof config.params.mode == "undefined" || config.params.mode === 0) { YAHOO.util.Dom.setStyle(box, "margin-top", "10px"); YAHOO.util.Dom.setStyle(box, "margin-bottom", "10px"); } parent.appendChild(box); var communitiesLvConfig = { domElement: this.communities, dataSource: this._dataSource, listenForNavKeys: true, fillOnScroll: false, threading: { format: "none", sortfunc: false }, placeholderText: "", rowFilter: function(row) { if (row.col8092 && (row.col8092 !== 0 && row.col8092 != 3)) { return false; } if (row.typedef.objtype == FIRSTCLASS.objTypes.conference) { return true; } // fix this to check the dir rooted field for type if (row.icon.id == 11138) { return false; } else { return row.status.view == 1; } }, rowHandler: FIRSTCLASS.apps.Search.handlers.communities }; this._communitiesListView = new FIRSTCLASS.layout.ListView(communitiesLvConfig); } content = $("fcSearchGroups"); if (content) { parent = content.parentNode; box = FIRSTCLASS.ui.widgets.buildContentBox(content, "fcWhiteContentBox"); YAHOO.util.Dom.setStyle(box, "margin-top", "10px"); YAHOO.util.Dom.setStyle(box, 'display', 'none'); var groupbox = box; parent.appendChild(box); var shown = false; var groupsLvConfig = { domElement: this.groups, dataSource: this._dataSource, listenForNavKeys: true, fillOnScroll: false, threading: { format: "none", sortfunc: false }, placeholderText: "", rowFilter: function(row) { if (row.col8108 && row.col8108 == 11) { if (!shown) { YAHOO.util.Dom.setStyle($('fcSearchGroups'), 'display', ''); YAHOO.util.Dom.setStyle(groupbox, 'display', ''); shown = true; } return true; } return false; }, rowHandler: FIRSTCLASS.apps.Search.handlers.people }; this._groupsListView = new FIRSTCLASS.layout.ListView(groupsLvConfig); } var key = escape(encodeURI(this._config.params.key)); /*if (this._config.params.escapedkey) { key = this._config.params.escapedkey; }*/ key = key.replace(/%20/g, " "); var searchpart = "__Search/?Srch=" + key; if (config.params.tagsonly) { searchpart = "__Search/?Tag=" + key; } if (config.params.mode == 1) { searchpart = "__Discover?What=Both"; } else if (config.params.mode == 2) { searchpart = "__Discover?What=Communities"; } else if (config.params.mode == 3) { searchpart = "__Discover?What=People"; } else if (config.params.mode == 4) { searchpart = "__RecentActivity?User=" + escape(encodeURI(config.params.user)) + "&CID=" + config.params.cid; } if (config.params.mode && config.params.count) { searchpart = searchpart + "&Count=" + config.params.count; } FIRSTCLASS.session.addHistoryEntry({ "uri": (FIRSTCLASS.session.baseURL + searchpart), "app": this/*, "cacheable": false*/ }); if (config.params.showoncomplete) { FIRSTCLASS.util.revealContents(); config.params.showoncomplete = false; } if ((!config.params.mode || config.params.mode < 1) && YAHOO.env.ua.ie === 0) { key = escape(encodeURI(this._config.params.key)); var hashpart = "#__Search/?Srch=" + key; if (config.params.tagsonly) { hashpart = "#__Search/?Tag=" + key; } window.location.hash = hashpart; } // setup event handlers this.activate(); this._dataSource.fetchRows(); if (config.params.mode && config.params.mode < 4) { var count = 20; if (config.params.count) { count = parseInt(config.params.count); } var newcount = count + 20; var uri = top.location.hash; uri = uri.replace("&Count="+count, ''); uri = uri + "&Count=" + newcount; var padheight = 100; if (this._peopleListView) { this._peopleListView.updatePadHeight(padheight); this._peopleListView.updatePadText({bottom:"" + FIRSTCLASS.locale.community.feed.more + ""}); } if (this._communitiesListView) { this._communitiesListView.updatePadHeight(padheight); this._communitiesListView.updatePadText({bottom:"" + FIRSTCLASS.locale.community.feed.more + ""}); } } FIRSTCLASS.util.revealContents(); }; FIRSTCLASS.apps.Search.prototype.onHeaderData = function(key, contents) { /* if (!this._paginator) { this._paginator = new YAHOO.widget.Paginator({ rowsPerPage: this._rowsPerPage, totalRecords: contents.lower, containers: ['searchpaginator'] }); this._paginator.render(); var that = this; this._paginator.subscribe('changeRequest',function(page) {that.handlePagination(page);}); }*/ }; FIRSTCLASS.apps.Search.prototype.filter = function(key) { if (key == "numitems") { return true; } return false; }; FIRSTCLASS.apps.Search.prototype.handlePagination = function(page) { this._dataSource.fetchRows(); this._paginator.setState(page); this._itemsListView.showPage(page.page); }; FIRSTCLASS.apps.Search.prototype.dispose = function() { if (this._itemsListView) { this._itemsListView.dispose(); } if (this._peopleListView) { this._peopleListView.dispose(); } if (this._communitiesListView) { this._communitiesListView.dispose(); } if (this._dataSource) { this._dataSource.close(); this._dataSource.dispose(); delete this._dataSource; } FIRSTCLASS.ui.MiniProfile.hideBoxNow(); }; FIRSTCLASS.apps.Search.prototype.deactivate = function() { if (this._itemsListView) { this._itemsListView.deactivate(); } if (this._peopleListView) { this._peopleListView.deactivate(); } if (this._communitiesListView) { this._communitiesListView.deactivate(); } if (this._dataSource) { this._dataSource.deactivate(); this._dataSource.close(); } FIRSTCLASS.ui.MiniProfile.hideBoxNow(); FIRSTCLASS.ui.navBar.setBottomText(""); }; FIRSTCLASS.apps.Search.prototype.activate = function() { FIRSTCLASS.ui.navBar.clearContentPane(); FIRSTCLASS.ui.Dom.replaceContentsWithElement(this._parentDiv, this._domElement); FIRSTCLASS.ui.navBar.setProfilePicture(FIRSTCLASS.session.ui.fcbase.absolute + "/images/SearchICON.png"); FIRSTCLASS.ui.navBar.setProfileStatus(""); FIRSTCLASS.ui.navBar.setProfileUnread(0); if (this._config.params && this._config.params.key) { FIRSTCLASS.ui.setDocumentTitle(FIRSTCLASS.locale.search.lbl.replace("%s", this._config.params.key)); FIRSTCLASS.ui.navBar.setTitle(FIRSTCLASS.locale.search.lbl.replace("%s", this._config.params.key)); } else if (typeof this._config.params.mode != "undefined") { var title = ""; if (this._config.params.mode == 1) { title = FIRSTCLASS.locale.search.discoverlbl; } else if (this._config.params.mode == 2) { title = FIRSTCLASS.locale.search.commlbl; } else if (this._config.params.mode == 3) { title = FIRSTCLASS.locale.search.bloglbl; } else if (this._config.params.mode == 4) { title = FIRSTCLASS.locale.doSub(FIRSTCLASS.locale.search.recentlbl, {name: this._config.params.user}); /* FIXME: Localize! */ } FIRSTCLASS.ui.setDocumentTitle(title); FIRSTCLASS.ui.navBar.setTitle(title); } if (this._itemsListView) { this._itemsListView.activate(); } if (this._peopleListView) { this._peopleListView.activate(); } if (this._communitiesListView) { this._communitiesListView.activate(); } if (this._dataSource) { this._dataSource.activate(); this._dataSource.open(); } FIRSTCLASS.ui.leftSideBar.hide(); FIRSTCLASS.ui.rightSideBar.hide(); FIRSTCLASS.ui.navBar.setBottomText(""); FIRSTCLASS.session.setActiveApplication(this, "search"); YAHOO.util.Dom.setStyle(document.body, "height", ""); YAHOO.util.Dom.setStyle(document.body, "overflow", ""); }; FIRSTCLASS.apps.Search.handlers = {}; FIRSTCLASS.apps.Search.handlers.people = { template:"
", createRow: function(row) { var el = document.createElement("div"); el.innerHTML = FIRSTCLASS.apps.Search.handlers.people.template; this.updateRow(row, el); return el; }, updateRow:function(row, element) { var img = element.firstChild.firstChild.firstChild.firstChild.firstChild; var name = element.firstChild.firstChild.firstChild.childNodes[1].firstChild; /* var img = FIRSTCLASS.ui.Dom.getChildByClassName('fcPersonIcon', element); var name = FIRSTCLASS.ui.Dom.getChildByClassName('fcPersonName', element);*/ if (row.col8108 && row.col8108 == 11) { img.src='/Icons/23003'; } else { img.src= FIRSTCLASS.util.User.getSmallProfPicUrlByCid(row.cid,true); img.setAttribute('fcattrs', row.name); YAHOO.util.Dom.setStyle(img, 'width', '20px'); YAHOO.util.Dom.setStyle(img, 'height', '27px'); } var fcid = 'user'; if (row.col8108 && row.col8108 == 11) { fcid = 'fcOrganization'; } name.innerHTML = "" + row.name + ''; name.firstChild.setAttribute('fcattrs', row.name); }, generateUniqueId:function(row) { return row.uid; } }; FIRSTCLASS.apps.Search.handlers.communities = { template:"
", createRow: function(row) { var el = document.createElement("div"); el.innerHTML = FIRSTCLASS.apps.Search.handlers.communities.template; this.updateRow(row, el); return el; }, updateRow:function(row, element) { var img = element.firstChild.firstChild.firstChild.firstChild.firstChild; var name = element.firstChild.firstChild.firstChild.childNodes[1].firstChild; /* var img = FIRSTCLASS.ui.Dom.getChildByClassName('fcSearchCommunityIcon', element); var name = FIRSTCLASS.ui.Dom.getChildByClassName('fcSearchCommunityName', element);*/ img.src = row.icon.uri; if (row.col8106 != 196611) { name.innerHTML = "" + FIRSTCLASS.lang.mlesc(row.name) + ""; } else { name.innerHTML = FIRSTCLASS.lang.mlesc(row.name) +"
" + "Request Membership"; } }, generateUniqueId:function(row) { return row.uid; } }; FIRSTCLASS.apps.Search.handlers.ECM = { template:"
"+FIRSTCLASS.locale.integrations.ecm.search.created+"
 on
"+FIRSTCLASS.locale.integrations.ecm.search.description+" 
"+FIRSTCLASS.locale.integrations.ecm.search.summary+" 
 
"+FIRSTCLASS.locale.integrations.ecm.search.view+""+FIRSTCLASS.locale.integrations.ecm.search.copy+"
", createRow: function(row) { var el = document.createElement("div"); el.innerHTML = FIRSTCLASS.apps.Search.handlers.ECM.template; this.updateRow(row, el); return el; }, updateRow:function(row, element) { var repository = FIRSTCLASS.apps.Integration.getRepositoryByObjid(row.objid); var icon = element.firstChild.firstChild.firstChild.firstChild.firstChild.firstChild; var person = element.firstChild.firstChild.firstChild.firstChild.childNodes[2].firstChild.firstChild; var name = element.firstChild.firstChild.firstChild.firstChild.childNodes[1].firstChild; var sz = element.firstChild.firstChild.firstChild.firstChild.childNodes[1].childNodes[1]; var creator = element.firstChild.firstChild.firstChild.childNodes[1].firstChild.childNodes[1]; var cdate = element.firstChild.firstChild.firstChild.childNodes[1].firstChild.childNodes[3]; var description = element.firstChild.firstChild.firstChild.childNodes[2].firstChild.childNodes[1]; var summary = element.firstChild.firstChild.firstChild.childNodes[3].firstChild.childNodes[1]; var tnail = element.firstChild.firstChild.firstChild.childNodes[3].firstChild.childNodes[2]; /* var icon = FIRSTCLASS.ui.Dom.getChildByClassName('fcHitIcon', element); // var score = FIRSTCLASS.ui.Dom.getChildByClassName('fcHitScore', element); var person = FIRSTCLASS.ui.Dom.getChildByClassName('fcHitPersonFace', element); var name = FIRSTCLASS.ui.Dom.getChildByClassName('fcHitName', element); var sz = FIRSTCLASS.ui.Dom.getChildByClassName('fcHitSize', element); var creator = FIRSTCLASS.ui.Dom.getChildByClassName('fcHitCreator', element); var cdate = FIRSTCLASS.ui.Dom.getChildByClassName('fcHitDate', element); var description = FIRSTCLASS.ui.Dom.getChildByClassName('fcHitDescription', element); var summary = FIRSTCLASS.ui.Dom.getChildByClassName('fcHitSummary', element); var tnail = FIRSTCLASS.ui.Dom.getChildByClassName('fcHitThumbnail', element);*/ var xuid = row.xuid; var view = element.firstChild.firstChild.firstChild.childNodes[4].childNodes[1].firstChild; var copy = element.firstChild.firstChild.firstChild.childNodes[4].childNodes[1].childNodes[1]; // var view = FIRSTCLASS.ui.Dom.getChildByClassName('ecmView', element); view.href = row.url; view.setAttribute('fcattrs', xuid); // var copy = FIRSTCLASS.ui.Dom.getChildByClassName('ecmCopy', element); copy.setAttribute('fcattrs', xuid); copy.setAttribute('fname', row.fname); copy.setAttribute('repository', repository.name); copy.setAttribute('version', row.version); if (row.tnlen > 0) { tnail.innerHTML = ""; // icon.src = row.thumbnail; // } else { } icon.src = "/Icons/" + FIRSTCLASS.util.Display.getIconID(row.fname); // } name.innerHTML = ""+row.fname+""; FIRSTCLASS.util.User.setSmallProfPicUrlByName(person, row.creat); sz.innerHTML = "("+FIRSTCLASS.util.Display.getFileSizeString(parseInt(row.fsize, 10))+")"; creator.innerHTML = "" + row.creat + ""; creator.setAttribute('fcid', 'user'); creator.setAttribute('fcattrs', row.creat); cdate.innerHTML = row.fdate; description.innerHTML = row.descr; summary.innerHTML = row.fsumm.replace(/\r\n/g, "
"); // score.innerHTML = row.score = "%"; }, generateUniqueId:function(row) { return row.uid; } }; FIRSTCLASS.apps.Search.handlers.content = { template:"
", createRow: function(row) { var el = document.createElement("div"); el.innerHTML = FIRSTCLASS.apps.Search.handlers.content.template; this.updateRow(row, el); return el; }, updateRow:function(row, element) { /* var img = FIRSTCLASS.ui.Dom.getChildByClassName('icon', element); var title = FIRSTCLASS.ui.Dom.getChildByClassName('title', element); var info = FIRSTCLASS.ui.Dom.getChildByClassName('info', element); var preview = FIRSTCLASS.ui.Dom.getChildByClassName('preview', element);*/ var img = element.firstChild.firstChild.firstChild.firstChild.firstChild; var title = element.firstChild.firstChild.firstChild.childNodes[1].firstChild; var info = element.firstChild.firstChild.childNodes[1].firstChild.firstChild; var preview = element.firstChild.firstChild.childNodes[2].firstChild.firstChild; var nm; switch (row.typedef.objtype) { case FIRSTCLASS.objTypes.odocument: if (row.col8106 && row.col8106 == 196620) { if (row.creatorcid) { nm = row.name; FIRSTCLASS.util.User.setSmallProfPicUrlByCid(img,row.creatorcid,false); img.setAttribute('fcattrs', nm); } else if (row.col8010) { FIRSTCLASS.util.User.setSmallProfPicUrlByName(img,row.col8010,false); } else { FIRSTCLASS.util.User.setSmallProfPicUrlByName(img,row.col8107,false); } YAHOO.util.Dom.setStyle(img, 'width', '50px'); } else { img.src = row.icon.uri; } break; case FIRSTCLASS.objTypes.fcfile: case FIRSTCLASS.objTypes.file: img.src = "/Icons/" + FIRSTCLASS.util.Display.getIconID(row.name); break; default: nm = row.name; if (row.creatorcid) { FIRSTCLASS.util.User.setSmallProfPicUrlByCid(img,row.creatorcid,false); img.setAttribute('fcattrs', nm); } else { FIRSTCLASS.util.User.setSmallProfPicUrlByName(img,nm,false); } YAHOO.util.Dom.setStyle(img, 'width', '50px'); } var infohtml = ""; var infolder = "in " + decodeURI(row.col15).replace(/\//g,""); var dstr = FIRSTCLASS.util.Date.getFriendlyDateString(row.lastmods); nm = row.name; if (row.col8082) { nm = row.col8082; } if (row.col8107) { infolder = row.col8107; } var subtype = FIRSTCLASS.subTypes.community; var uri = FIRSTCLASS.session.baseURL + FIRSTCLASS.lang.removeSlashUrl(row.col15, true); if (row.col8106 && row.col8106 == 196614) { uri = FIRSTCLASS.lang.removeSlashUrl(row.uri); uri = uri.substr(0, uri.lastIndexOf('/')); } var type = FIRSTCLASS.locale.search.items.discussion; var params = {title: row.name.replace(/\//g,""), unread:0, icon: row.icon.uri, itemthread:row.threadid}; var fmt = FIRSTCLASS.locale.search.items.editfmt; var pv = ""; switch (row.typedef.objtype) { case FIRSTCLASS.objTypes.odocument: type = FIRSTCLASS.locale.search.items.wiki; pv = ""; if (row.expandedPreview) { pv = row.expandedPreview; } if (row.col8106 && row.col8106 == 196620) { type = FIRSTCLASS.locale.search.items.blogpost; infolder = FIRSTCLASS.locale.search.items.blogwhere.replace("$where$", row.col8107); subtype = FIRSTCLASS.subTypes.profile; uri = FIRSTCLASS.util.User.getProfileUrlByCid(row.cid); params.uid = row.uid; params.name = row.col8107; } // title.innerHTML = '' + row.subject + ''; //params.title = row.subject; if (row.version == 1) { fmt = FIRSTCLASS.locale.search.items.docnew; } if (row.col8101) { pv = row.col8101; } break; case FIRSTCLASS.objTypes.fcfile: case FIRSTCLASS.objTypes.file: // title.innerHTML = '' + row.name + ''; params.title = row.col8018; if (!params.title) { params.title = decodeURI(row.col15.replace(/\//g, "")); } type = FIRSTCLASS.locale.search.items.doc; if (row.version == 1) { fmt = FIRSTCLASS.locale.search.items.filenew; } else { fmt = FIRSTCLASS.locale.search.items.editfmt; } if (row.col8101) { pv = row.col8101; } break; default: if (row.col8106 && row.col8106 == 196620) { type = FIRSTCLASS.locale.search.items.blogreply; infolder = row.col8107 + "'s Blog"; subtype = FIRSTCLASS.subTypes.profile; uri = FIRSTCLASS.util.User.getProfileUrlByCid(row.cid); params.uid = row.uid; params.name = row.col8107; //params.title = row.subject; } else if (row.replyobjtype == FIRSTCLASS.objTypes.fcfile || row.replyobjtype == FIRSTCLASS.objTypes.file) { type = FIRSTCLASS.locale.search.items.filereply; } fmt = FIRSTCLASS.locale.search.items.postfmt; pv = row.expandedPreview; } infohtml += fmt.replace("$type$", type).replace("$where$", infolder).replace("$date$", dstr).replace("$name$", nm); info.innerHTML = infohtml; //var funcstr = "FIRSTCLASS.loadApplication(\""+ uri + "\", " + FIRSTCLASS.objTypes.conference + ", " + subtype + ", " + FIRSTCLASS.lang.serialize(params) + ");"; if (row.itemdata) { pv = row.itemdata.body; } if (typeof pv == "undefined") { pv = ""; } if (pv.length > 160) { pv = pv.substr(0,160) + " ..."; } pv = "
" + pv + "
"; preview.innerHTML = pv; var imgs = preview.getElementsByTagName("IMG"); for (var i = 0; i < imgs.length; i++) { img = imgs[i]; YAHOO.util.Dom.setStyle(img, "height", "auto"); } //title.innerHTML = "" + row.subject + ''; if (row.col8106 && row.col8106 == 196620) { title.innerHTML = "" + params.title + ''; } else { var subject = row.subject; if (row.typedef.objtype == FIRSTCLASS.objTypes.formdoc || row.typedef.objtype == FIRSTCLASS.objTypes.odocument || row.typedef.objtype == FIRSTCLASS.objTypes.file || row.typedef.objtype == FIRSTCLASS.objTypes.fcfile) { subject = row.col8010; } if (!subject || subject.length === 0) { subject = "No Subject"; } title.innerHTML = "" + subject + ""; } }, generateUniqueId:function(row) { return row.uid; } }; FIRSTCLASS.apps.Search.prototype.eventHandlers = { click: { userProfile: function(that, fcevent) { var uri; uri = fcevent.fcattrs; var iconuri = fcevent.target.getAttribute("icon"); var name = fcevent.target.getAttribute("name"); var thread = fcevent.target.getAttribute("itemthread"); var item = fcevent.target.getAttribute("messageid"); var uid = fcevent.target.getAttribute("uid"); var params = { title: name, icon: iconuri, fromSearch:true }; if (uri.indexOf("Open-Conf") < 0) { params.fromSearch = false; } if (thread) { params.itemthread = thread; } if (item) { params.messageid = item; } if (uid) { params.uid = parseInt(uid, 10); } FIRSTCLASS.loadApplication(uri, FIRSTCLASS.objTypes.conference, FIRSTCLASS.subTypes.profile, params); }, searchcommunity: function(that, fcevent) { var uri = fcevent.fcattrs; var iconuri = fcevent.target.getAttribute("icon"); var name = fcevent.target.getAttribute("name"); var thread = fcevent.target.getAttribute("itemthread"); var item = fcevent.target.getAttribute("messageid"); var cid = fcevent.target.getAttribute("cid"); var params = { title: name, icon: iconuri, fromSearch:true }; if (uri.indexOf("Open-Conf") < 0) { params.fromSearch = false; } if (thread) { params.itemthread = thread; } if (item) { params.messageid = item; } if (cid) { params.lconfcid = parseInt(cid, 10); } FIRSTCLASS.loadApplication(uri, FIRSTCLASS.objTypes.conference, FIRSTCLASS.subTypes.community, params); }, joincommunity: function(that, fcevent) { var bd = document.createElement("div"); bd.innerHTML = "
Request Membership
" + "" + "
" + FIRSTCLASS.locale.search.requesttojoin.slbl + " " + FIRSTCLASS.locale.search.requesttojoin.subject + "
" + FIRSTCLASS.locale.search.requesttojoin.blbl + " " + "
"; var handleSubmit = function() { var subject = FIRSTCLASS.locale.search.requesttojoin.subject; var body = $('fcJoinCommunityInput').value; FIRSTCLASS.util.requestToJoin(fcevent.fcattrs, subject, body); fcevent.target.innerHTML = FIRSTCLASS.locale.search.requesttojoin.sent; fcevent.target.setAttribute('fcid', ''); this.hide(); this.destroy(); }; var handleCancel = function() { this.cancel(); }; var dlg = new YAHOO.widget.Dialog(bd, { visible: true, fixedcenter: true, constraintoviewport:true, buttons: [ {text: FIRSTCLASS.locale.search.requesttojoin.dosend, handler: handleSubmit, isDefault: true}, {text: FIRSTCLASS.locale.search.requesttojoin.cancel, handler:handleCancel} ]}); dlg.render(document.body); dlg.show(); /* var subject = prompt("Please enter a subject:", "Can I come In?"); var body = prompt("Please enter a message:", "Pretty Please?"); FIRSTCLASS.util.requestToJoin(fcevent.fcattrs, subject, body); fcevent.target.innerHTML = "Membership request sent"; fcevent.target.setAttribute('fcid', '');*/ }, less: function(that, fcevent) { var uri = FIRSTCLASS.lang.removeSlashUrl(fcevent.fcattrs); var rows = that._dataSource.query("uri", 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) { var row = rows[0][1]; //var row = el.row; row.bitemdata = row.itemdata; row.itemdata = false; that._dataSource.notifyRowChanged(row, {status:row.status,itemdata:row.bitemdata}); //that.listView.changeSelection(el.el, false, true, el.row); fcevent.target.innerHTML = "more..."; } }, more: function(that, fcevent) { var uri = FIRSTCLASS.lang.removeSlashUrl(fcevent.fcattrs); var rows = that._dataSource.query("uri", 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) { var row = rows[0][1]; // var row = el.row; if (row.bitemdata) { row.itemdata = row.bitemdata; row.bitemdata = false; that._dataSource.notifyRowChanged(row, {status:row.status,itemdata:false}); } else { that._dataSource.fetchItem(row); } //that.listView.changeSelection(el.el, false, true, el.row); fcevent.target.innerHTML = "loading..."; } } } }; FIRSTCLASS.apps.Search.prototype.handleEvent = function(event, fcevent) { var handled = false, handler, tab, rv, handlers; if (this._tabView) { tab = this._tabView.get('activeTab').get('label'); if (this._integrations[tab]) { handled = this._integrations[tab].handleEvent(event, fcevent); } } handlers = this.eventHandlers[event.type]; if (!handled && handlers) { handler = handlers[fcevent.fcid]; if (handler) { rv = handler(this, fcevent); if (typeof rv == "undefined") { rv = true; } } } }; // class variables FIRSTCLASS.apps.Search.prototype._dataSource = null; FIRSTCLASS.apps.Search.prototype._domElement = null; // class methods YAHOO.register("fcSearch", FIRSTCLASS.apps.Search, {version: "0.0.1", build: "1"});