Merge from 1.5 branch: NIHVIVO-3977 Incorporate improvements in OpenSocial for 1.5.1. Also, make shinding_orng_tables.sql re-runnable.

This commit is contained in:
j2blake 2012-10-01 16:53:43 +00:00
parent b9cd04f0fa
commit e0a255c8b2
9 changed files with 443 additions and 351 deletions

View file

@ -9,21 +9,23 @@ INSERT INTO `orng_apps` (`appid`, `name`, `url`, `PersonFilterID`, `enabled`, `c
(102, 'Faculty Mentor', 'http://dev-profiles.ucsf.edu/orng/Mentor.xml', NULL, 0, NULL), (102, 'Faculty Mentor', 'http://dev-profiles.ucsf.edu/orng/Mentor.xml', NULL, 0, NULL),
(103, 'Websites', 'http://dev-profiles.ucsf.edu/orng/Links.xml', NULL, 1, NULL), (103, 'Websites', 'http://dev-profiles.ucsf.edu/orng/Links.xml', NULL, 1, NULL),
(104, 'Profile List', 'http://dev-profiles.ucsf.edu/orng/ProfileListTool.xml', NULL, 1, 'JSONPersonIds'), (104, 'Profile List', 'http://dev-profiles.ucsf.edu/orng/ProfileListTool.xml', NULL, 1, 'JSONPersonIds'),
(106, 'RDF Test Gadget', 'http://dev-profiles.ucsf.edu/orng/RDFTest.xml', NULL, 1, NULL); (106, 'RDF Test Gadget', 'http://dev-profiles.ucsf.edu/orng/RDFTest.xml', NULL, 1, NULL),
(112, 'Twitter', 'http://dev-profiles.ucsf.edu/ORNG/Twitter.xml', NULL, 1, NULL);
DELETE FROM `orng_app_views`; DELETE FROM `orng_app_views`;
INSERT INTO `orng_app_views` (`appid`, `viewer_req`, `owner_req`, `page`, `view`, `closed_width`, `open_width`, `start_closed`, `chromeId`, `display_order`) VALUES INSERT INTO `orng_app_views` (`appid`, `viewer_req`, `owner_req`, `page`, `view`, `chromeId`, `opt_params`, `display_order`) VALUES
(100, NULL, NULL, 'search', NULL, 600, 600, 1, 'gadgets-search', NULL), (100, NULL, NULL, 'search', NULL, 'gadgets-search', NULL, NULL),
(101, NULL, 'R', 'individual', 'profile', 290, 600, 1, 'gadgets-view', 3), (101, NULL, 'R', 'individual', 'profile', 'gadgets-view', '{''gadget_class'':''ORNGToggleGadget'', ''start_closed'':1, ''closed_width'':290}', 4),
(101, NULL, NULL, 'individual-EDIT-MODE', 'home', 700, 700, 1, 'gadgets-edit', NULL), (101, NULL, NULL, 'individual-EDIT-MODE', 'home', 'gadgets-edit', '{''gadget_class'':''ORNGToggleGadget'', ''start_closed'':1, ''closed_width'':700}', 4),
(102, NULL, 'R', 'individual', 'profile', 290, 600, 1, 'gadgets-view', 2), (102, NULL, 'R', 'individual', 'profile', 'gadgets-view', '{''gadget_class'':''ORNGToggleGadget'', ''start_closed'':1, ''closed_width'':290}', 3),
(102, NULL, NULL, 'individual-EDIT-MODE', 'home', 700, 700, 1, 'gadgets-edit', NULL), (102, NULL, NULL, 'individual-EDIT-MODE', 'home', 'gadgets-edit', '{''gadget_class'':''ORNGToggleGadget'', ''start_closed'':1, ''closed_width'':700}', 3),
(103, NULL, NULL, 'individual-EDIT-MODE', 'home', 700, 700, 1, 'gadgets-edit', NULL), (103, NULL, NULL, 'individual-EDIT-MODE', 'home', 'gadgets-edit', '{''gadget_class'':''ORNGToggleGadget'', ''start_closed'':1, ''closed_width'':700}', NULL),
(103, NULL, 'R', 'individual', 'profile', 290, 600, 0, 'gadgets-view', 1), (103, NULL, 'R', 'individual', 'profile', 'gadgets-view', '{''gadget_class'':''ORNGToggleGadget'', ''start_closed'':0, ''closed_width'':290}', 1),
(104, 'U', NULL, 'search', 'small', 160, 160, 0, 'gadgets-tools', NULL), (104, 'U', NULL, 'search', 'small', 'gadgets-tools', NULL, NULL),
(104, 'U', NULL, 'gadgetDetails', 'canvas', 700, 700, 0, 'gadgets-detail', NULL), (104, 'U', NULL, 'gadgetDetails', 'canvas', 'gadgets-detail', NULL, NULL),
(104, 'U', NULL, 'SimilarPeople.aspx', 'small', 160, 160, 0, 'gadgets-tools', NULL), (104, 'U', NULL, 'individual', 'small', 'gadgets-view', NULL, NULL),
(104, 'U', NULL, 'individual', 'small', 290, 290, 0, 'gadgets-view', NULL), (106, NULL, NULL, 'individual-EDIT-MODE', 'home', 'gadgets-edit', '{''gadget_class'':''ORNGToggleGadget'', ''start_closed'':1, ''closed_width'':700}', NULL),
(104, 'U', NULL, 'CoAuthors.aspx', 'small', 160, 160, 0, 'gadgets-tools', NULL), (112, NULL, 'R', 'individual', 'profile', 'gadgets-view', '{''gadget_class'':''ORNGToggleGadget'', ''start_closed'':0, ''closed_width'':290}', 2),
(106, NULL, NULL, 'individual-EDIT-MODE', 'home', 700, 700, 1, 'gadgets-edit', NULL); (112, NULL, NULL, 'individual-EDIT-MODE', 'home', 'gadgets-edit', '{''gadget_class'':''ORNGToggleGadget'', ''start_closed'':1, ''closed_width'':700}', 2);

View file

@ -3,7 +3,8 @@
-- Table structure for table `orng_activity` -- Table structure for table `orng_activity`
-- --
CREATE TABLE IF NOT EXISTS `orng_activity` ( DROP TABLE IF EXISTS `orng_activity`;
CREATE TABLE `orng_activity` (
`activityId` int(11) NOT NULL AUTO_INCREMENT, `activityId` int(11) NOT NULL AUTO_INCREMENT,
`userId` varchar(255) default NULL, `userId` varchar(255) default NULL,
`appId` int(11) default NULL, `appId` int(11) default NULL,
@ -18,7 +19,8 @@ CREATE TABLE IF NOT EXISTS `orng_activity` (
-- Table structure for table `orng_appdata` -- Table structure for table `orng_appdata`
-- --
CREATE TABLE IF NOT EXISTS `orng_appdata` ( DROP TABLE IF EXISTS `orng_appdata`;
CREATE TABLE `orng_appdata` (
`userId` varchar(255) NOT NULL, `userId` varchar(255) NOT NULL,
`appId` int(11) NOT NULL, `appId` int(11) NOT NULL,
`keyname` varchar(255) NOT NULL, `keyname` varchar(255) NOT NULL,
@ -34,7 +36,8 @@ CREATE TABLE IF NOT EXISTS `orng_appdata` (
-- Table structure for table `orng_apps` -- Table structure for table `orng_apps`
-- --
CREATE TABLE IF NOT EXISTS `orng_apps` ( DROP TABLE IF EXISTS `orng_apps`;
CREATE TABLE `orng_apps` (
`appid` int(11) NOT NULL, `appid` int(11) NOT NULL,
`name` varchar(255) NOT NULL, `name` varchar(255) NOT NULL,
`url` varchar(255) NOT NULL, `url` varchar(255) NOT NULL,
@ -50,7 +53,8 @@ CREATE TABLE IF NOT EXISTS `orng_apps` (
-- Table structure for table `orng_app_registry` -- Table structure for table `orng_app_registry`
-- --
CREATE TABLE IF NOT EXISTS `orng_app_registry` ( DROP TABLE IF EXISTS `orng_app_registry`;
CREATE TABLE `orng_app_registry` (
`appid` int(11) NOT NULL, `appid` int(11) NOT NULL,
`personId` varchar(255) NOT NULL, `personId` varchar(255) NOT NULL,
`createdDT` datetime NOT NULL, `createdDT` datetime NOT NULL,
@ -63,17 +67,16 @@ CREATE TABLE IF NOT EXISTS `orng_app_registry` (
-- Table structure for table `orng_app_views` -- Table structure for table `orng_app_views`
-- --
CREATE TABLE IF NOT EXISTS `orng_app_views` ( DROP TABLE IF EXISTS `orng_app_views`;
CREATE TABLE `orng_app_views` (
`appid` int(11) NOT NULL, `appid` int(11) NOT NULL,
`viewer_req` char(1) default NULL, `viewer_req` char(1) default NULL,
`owner_req` char(1) default NULL, `owner_req` char(1) default NULL,
`page` varchar(50) default NULL, `page` varchar(50) default NULL,
`view` varchar(50) default NULL, `view` varchar(50) default NULL,
`closed_width` int(11) default NULL,
`open_width` int(11) default NULL,
`start_closed` tinyint(1) default NULL,
`chromeId` varchar(50) default NULL, `chromeId` varchar(50) default NULL,
`display_order` int(11) default NULL `display_order` int(11) default NULL,
`opt_params` varchar(255) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1; ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- -------------------------------------------------------- -- --------------------------------------------------------
@ -82,7 +85,8 @@ CREATE TABLE IF NOT EXISTS `orng_app_views` (
-- Table structure for table `orng_messages` -- Table structure for table `orng_messages`
-- --
CREATE TABLE IF NOT EXISTS `orng_messages` ( DROP TABLE IF EXISTS `orng_messages`;
CREATE TABLE `orng_messages` (
`msgId` varchar(255) NOT NULL, `msgId` varchar(255) NOT NULL,
`senderId` varchar(255) default NULL, `senderId` varchar(255) default NULL,
`recipientId` varchar(255) default NULL, `recipientId` varchar(255) default NULL,
@ -96,6 +100,10 @@ CREATE TABLE IF NOT EXISTS `orng_messages` (
-- -------------------------------------------------------- -- --------------------------------------------------------
DROP PROCEDURE IF EXISTS `orng_registerAppPerson`;
DROP PROCEDURE IF EXISTS `orng_upsertAppData`;
DROP PROCEDURE IF EXISTS `orng_deleteAppData`;
DELIMITER // DELIMITER //
CREATE PROCEDURE orng_registerAppPerson (uid varchar(255), aid INT, v BOOL) CREATE PROCEDURE orng_registerAppPerson (uid varchar(255), aid INT, v BOOL)
BEGIN BEGIN
@ -131,7 +139,7 @@ END //
DELIMITER ; DELIMITER ;
DELIMITER // DELIMITER //
CREATE PROCEDURE orng_deleteAppData(uid varchar(255),aid INT, kn varchar(255)) CREATE PROCEDURE orng_deleteAppData(uid varchar(255), aid INT, kn varchar(255))
BEGIN BEGIN
DELETE FROM orng_appdata WHERE userId = uid AND appId = aid and keyname = kn; DELETE FROM orng_appdata WHERE userId = uid AND appId = aid and keyname = kn;
-- if keyname is VISIBLE, do more -- if keyname is VISIBLE, do more

View file

@ -159,9 +159,6 @@ shindig.json-rpc.result-field=result
shindig.accelerate.remapInternalServerError=true shindig.accelerate.remapInternalServerError=true
shindig.proxy.remapInternalServerError=true shindig.proxy.remapInternalServerError=true
shindig.signing.key-file=@TOKEN_KEY_FILE@
shindig.signing.key-name=mykey
##################################################################################### #####################################################################################
# #
# Open Research Networking Gadgets Items # Open Research Networking Gadgets Items

Binary file not shown.

View file

@ -37,7 +37,7 @@ public class GadgetSpec {
ResultSet rset = null; ResultSet rset = null;
try { try {
String sqlCommand = "select page, viewer_req, owner_req, view, closed_width, open_width, start_closed, chromeId, display_order from orng_app_views where appId = " String sqlCommand = "select page, viewer_req, owner_req, view, chromeId, opt_params, display_order from orng_app_views where appId = "
+ appId; + appId;
conn = ds.getConnection(); conn = ds.getConnection();
stmt = conn.createStatement(); stmt = conn.createStatement();
@ -47,9 +47,8 @@ public class GadgetSpec {
rset.getString(1), rset.getString(1),
new GadgetViewRequirements(rset.getString(1), rset new GadgetViewRequirements(rset.getString(1), rset
.getString(2), rset.getString(3), rset .getString(2), rset.getString(3), rset
.getString(4), rset.getInt(5), rset .getString(4), rset.getString(5), rset
.getInt(6), rset.getBoolean(7), rset .getString(6), rset.getInt(7)));
.getString(8), rset.getInt(9)));
} }
} finally { } finally {
try { try {

View file

@ -4,31 +4,24 @@ public class GadgetViewRequirements {
private char viewerReq; // U for User or null for no requirement private char viewerReq; // U for User or null for no requirement
private char ownerReq; // R for Registered or null for no requirement private char ownerReq; // R for Registered or null for no requirement
private String view; private String view;
private int closedWidth;
private int openWidth;
private boolean startClosed;
private String chromeId; private String chromeId;
private String optParams;
private int display_order; private int display_order;
public GadgetViewRequirements(char viewerReq, char ownerReq, public GadgetViewRequirements(char viewerReq, char ownerReq,
String view, int closedWidth, int openWidth, boolean startClosed, String view, String chromeId, String optParams, int display_order) {
String chromeId, int display_order) {
this.viewerReq = viewerReq; this.viewerReq = viewerReq;
this.ownerReq = ownerReq; this.ownerReq = ownerReq;
this.view = view; this.view = view;
this.closedWidth = closedWidth;
this.openWidth = openWidth;
this.startClosed = startClosed;
this.chromeId = chromeId; this.chromeId = chromeId;
this.optParams = optParams;
this.display_order = display_order; this.display_order = display_order;
} }
public GadgetViewRequirements(String page, String viewerReq, public GadgetViewRequirements(String page, String viewerReq,
String ownerReq, String view, int closedWidth, int openWidth, String ownerReq, String view, String chromeId, String optParams, int display_order) {
boolean startClosed, String chromeId, int display_order) {
this(viewerReq != null ? viewerReq.charAt(0) : ' ', this(viewerReq != null ? viewerReq.charAt(0) : ' ',
ownerReq != null ? ownerReq.charAt(0) : ' ', view, closedWidth, ownerReq != null ? ownerReq.charAt(0) : ' ', view, chromeId, optParams, display_order);
openWidth, startClosed, chromeId, display_order);
} }
public char getViewerReq() { public char getViewerReq() {
@ -43,22 +36,14 @@ public class GadgetViewRequirements {
return view; return view;
} }
public int getClosedWidth() {
return closedWidth;
}
public int getOpenWidth() {
return openWidth;
}
public boolean getStartClosed() {
return startClosed;
}
public String getChromeId() { public String getChromeId() {
return chromeId; return chromeId;
} }
public String getOptParams() {
return optParams != null && optParams.trim().length() > 0 ? optParams : "{}";
}
int getDisplayOrder() { int getDisplayOrder() {
return display_order; return display_order;
} }

View file

@ -353,15 +353,13 @@ public class OpenSocialManager {
public String getGadgetJavascript() { public String getGadgetJavascript() {
String lineSeparator = System.getProperty("line.separator"); String lineSeparator = System.getProperty("line.separator");
String gadgetScriptText = "var my = {};" + lineSeparator String gadgetScriptText = "var my = {};" + lineSeparator
+ "my.gadgetSpec = function(appId, name, url, secureToken, view, closed_width, open_width, start_closed, chrome_id, visible_scope) {" + "my.gadgetSpec = function(appId, name, url, secureToken, view, chrome_id, opt_params, visible_scope) {"
+ lineSeparator + "this.appId = appId;" + lineSeparator + lineSeparator + "this.appId = appId;" + lineSeparator
+ "this.name = name;" + lineSeparator + "this.url = url;" + "this.name = name;" + lineSeparator + "this.url = url;"
+ lineSeparator + "this.secureToken = secureToken;" + lineSeparator + "this.secureToken = secureToken;"
+ lineSeparator + "this.view = view || 'default';" + lineSeparator + "this.view = view || 'default';"
+ lineSeparator + "this.closed_width = closed_width;" + lineSeparator + "this.chrome_id = chrome_id;"
+ lineSeparator + "this.open_width = open_width;" + lineSeparator + "this.opt_params = opt_params;" + lineSeparator
+ lineSeparator + "this.start_closed = start_closed;"
+ lineSeparator + "this.chrome_id = chrome_id;" + lineSeparator
+ "this.visible_scope = visible_scope;" + lineSeparator + "};" + "this.visible_scope = visible_scope;" + lineSeparator + "};"
+ lineSeparator + "my.pubsubData = {};" + lineSeparator; + lineSeparator + "my.pubsubData = {};" + lineSeparator;
for (String key : getPubsubData().keySet()) { for (String key : getPubsubData().keySet()) {
@ -377,10 +375,7 @@ public class OpenSocialManager {
gadgetScriptText += "new my.gadgetSpec(" + gadget.getAppId() + ",'" gadgetScriptText += "new my.gadgetSpec(" + gadget.getAppId() + ",'"
+ gadget.getName() + "','" + gadget.getGadgetURL() + "','" + gadget.getName() + "','" + gadget.getGadgetURL() + "','"
+ gadget.getSecurityToken() + "','" + gadget.getView() + gadget.getSecurityToken() + "','" + gadget.getView()
+ "'," + gadget.getClosedWidth() + "," + "','" + gadget.getChromeId() + "'," + gadget.getOptParams() + ",'"
+ gadget.getOpenWidth() + ","
+ (gadget.getStartClosed() ? "1" : "0") + ",'"
+ gadget.getChromeId() + "','"
+ gadget.getGadgetSpec().getVisibleScope() + "'), "; + gadget.getGadgetSpec().getVisibleScope() + "'), ";
} }
gadgetScriptText = gadgetScriptText.substring(0, gadgetScriptText = gadgetScriptText.substring(0,

View file

@ -73,23 +73,6 @@ public class PreparedGadget implements Comparable<PreparedGadget> {
} }
} }
public int getOpenWidth() {
GadgetViewRequirements reqs = getGadgetViewRequirements();
return reqs != null ? reqs.getOpenWidth() : 0;
}
public int getClosedWidth() {
GadgetViewRequirements reqs = getGadgetViewRequirements();
return reqs != null ? reqs.getClosedWidth() : 0;
}
public boolean getStartClosed() {
GadgetViewRequirements reqs = getGadgetViewRequirements();
// if the page specific reqs are present, honor those. Otherwise defaut
// to true for regular gadgets, false for sandbox gadgets
return reqs != null ? reqs.getStartClosed() : !gadgetSpec.fromSandbox();
}
public String getChromeId() { public String getChromeId() {
GadgetViewRequirements reqs = getGadgetViewRequirements(); GadgetViewRequirements reqs = getGadgetViewRequirements();
if (reqs != null) { if (reqs != null) {
@ -112,6 +95,11 @@ public class PreparedGadget implements Comparable<PreparedGadget> {
} }
} }
public String getOptParams() {
GadgetViewRequirements reqs = getGadgetViewRequirements();
return reqs != null ? reqs.getOptParams() : "{}";
}
public String getCanvasURL() throws UnsupportedEncodingException { public String getCanvasURL() throws UnsupportedEncodingException {
return "~/gadget?appId=" + getAppId() + "&Person=" return "~/gadget?appId=" + getAppId() + "&Person="
+ URLEncoder.encode(helper.getOwnerId(), "UTF-8"); + URLEncoder.encode(helper.getOwnerId(), "UTF-8");

View file

@ -118,6 +118,9 @@ gadgets.pubsubrouter.init(function(id) {
_gaq.push(['_trackEvent', my.gadgets[moduleId].name, 'go_to_profile', message]); _gaq.push(['_trackEvent', my.gadgets[moduleId].name, 'go_to_profile', message]);
document.location.href = '/' + location.pathname.split('/')[1] + '/display/n' + message; document.location.href = '/' + location.pathname.split('/')[1] + '/display/n' + message;
} }
else if (channel == 'hide') {
document.getElementById(sender).parentNode.parentNode.style.display = 'none';
}
else if (channel == 'JSONPersonIds' || channel == 'JSONPubMedIds') { else if (channel == 'JSONPersonIds' || channel == 'JSONPubMedIds') {
// do nothing, no need to alert // do nothing, no need to alert
} }
@ -222,7 +225,7 @@ my.requestGadgetMetaData = function(view, opt_callback) {
my.renderableGadgets = []; my.renderableGadgets = [];
my.generateGadgets = function(metadata) { my.generateGadgets = function (metadata) {
// put them in moduleId order // put them in moduleId order
for (var i = 0; i < metadata.gadgets.length; i++) { for (var i = 0; i < metadata.gadgets.length; i++) {
var moduleId = metadata.gadgets[i].moduleId; var moduleId = metadata.gadgets[i].moduleId;
@ -234,9 +237,17 @@ my.generateGadgets = function(metadata) {
height = viewPrefs.preferredHeight || height; height = viewPrefs.preferredHeight || height;
width = viewPrefs.preferredWidth || width; width = viewPrefs.preferredWidth || width;
} }
my.renderableGadgets[moduleId] = shindig.container.createGadget({'specUrl': metadata.gadgets[i].url, 'secureToken': my.gadgets[moduleId].secureToken,
var opt_params = { 'specUrl': metadata.gadgets[i].url, 'secureToken': my.gadgets[moduleId].secureToken,
'title': metadata.gadgets[i].title, 'userPrefs': metadata.gadgets[i].userPrefs, 'title': metadata.gadgets[i].title, 'userPrefs': metadata.gadgets[i].userPrefs,
'height': height, 'width': width, 'debug': my.debug}); 'height': height, 'width': width, 'debug': my.debug};
// do a shallow merge of the opt_params from the database. This will overwrite anything with the same name, and we like that
for (var attrname in my.gadgets[moduleId].opt_params) {
opt_params[attrname] = my.gadgets[moduleId].opt_params[attrname];
}
my.renderableGadgets[moduleId] = shindig.container.createGadget(opt_params);
// set the metadata for easy access // set the metadata for easy access
my.renderableGadgets[moduleId].setMetadata(metadata.gadgets[i]); my.renderableGadgets[moduleId].setMetadata(metadata.gadgets[i]);
} }
@ -249,16 +260,20 @@ my.generateGadgets = function(metadata) {
} }
if (ready) { if (ready) {
shindig.container.addGadgets(my.renderableGadgets ); shindig.container.addGadgets(my.renderableGadgets);
shindig.container.renderGadgets(); shindig.container.renderGadgets();
} }
}; };
my.init = function() { my.init = function() {
shindig.container.gadgetClass = OrngGadget; // overwrite this RPC function. Do it at this level so that rpc.f (this.f) is accessible for getting module ID
shindig.container.layoutManager = new OrngLayoutManager(); // gadgets.rpc.register('requestNavigateTo', doProfilesNavigation);
shindig.container = new ORNGContainer();
shindig.container.gadgetService = new ORNGGadgetService();
shindig.container.layoutManager = new ORNGLayoutManager();
shindig.container.setNoCache(my.noCache); shindig.container.setNoCache(my.noCache);
shindig.container.gadgetService = new OrngGadgetService();
// since we render multiple views, we need to do somethign fancy by swapping out this value in getIframeUrl // since we render multiple views, we need to do somethign fancy by swapping out this value in getIframeUrl
shindig.container.setView('REPLACE_THIS_VIEW'); shindig.container.setView('REPLACE_THIS_VIEW');
@ -275,34 +290,83 @@ my.init = function() {
} }
}; };
// OrngGadgetService //ORNGContainer
ORNGContainer = function() {
shindig.IfrContainer.call(this);
};
OrngGadgetService = function() { ORNGContainer.inherits(shindig.IfrContainer);
ORNGContainer.prototype.createGadget = function (opt_params) {
if (opt_params.gadget_class) {
return new window[opt_params.gadget_class](opt_params);
}
else {
return new ORNGGadget(opt_params);
}
}
//ORNGLayoutManager.
ORNGLayoutManager = function() {
shindig.LayoutManager.call(this);
};
ORNGLayoutManager.inherits(shindig.LayoutManager);
ORNGLayoutManager.prototype.getGadgetChrome = function(gadget) {
var layoutRoot = document.getElementById(my.gadgets[gadget.id].chrome_id);
if (layoutRoot) {
var chrome = document.createElement('div');
chrome.className = 'gadgets-gadget-chrome';
layoutRoot.appendChild(chrome);
return chrome;
} else {
return null;
}
};
//ORNGGadgetService
ORNGGadgetService = function() {
shindig.IfrGadgetService.call(this); shindig.IfrGadgetService.call(this);
}; };
OrngGadgetService.inherits(shindig.IfrGadgetService); ORNGGadgetService.inherits(shindig.IfrGadgetService);
OrngGadgetService.prototype.requestNavigateTo = function(view, opt_params) { ORNGGadgetService.prototype.setTitle = function (title) {
var viewConfig = gadgets.config.get('views')[view]; var moduleId = shindig.container.gadgetService.getGadgetIdFromModuleId(this.f);
var url = '/' + location.pathname.split('/')[1] + '/' + viewConfig.urlTemplate; if (my.gadgets[moduleId].view == 'canvas') {
ORNGGadgetService.setCanvasTitle(title);
}
else {
var element = document.getElementById(this.f + '_title');
element.innerHTML = my.renderableGadgets[moduleId].getTitleHtml(title);
}
};
ORNGGadgetService.setCanvasTitle = function (title) {
document.getElementById("gadgets-title").innerHTML = title.replace(/&/g, '&amp;').replace(/</g, '&lt;');
}
ORNGGadgetService.prototype.requestNavigateTo = function(view, opt_params) {
var urlTemplate = gadgets.config.get('views')[view].urlTemplate;
var url = urlTemplate || 'OpenSocial.aspx?';
url += window.location.search.substring(1); url += window.location.search.substring(1);
// remove appId if present // remove appId if present
url = my.removeParameterFromURL(url, 'appId'); url = my.removeParameterFromURL(url, 'appId');
// Add appId if isOnlyVisible is TRUE for this view // Add appId if the URL Template begins with the word 'Gadget'
if (viewConfig.isOnlyVisible) { if (urlTemplate.indexOf('Gadget') == 0) {
var moduleId = shindig.container.gadgetService.getGadgetIdFromModuleId(this.f); var moduleId = shindig.container.gadgetService.getGadgetIdFromModuleId(this.f);
var appId = my.gadgets[moduleId].appId; var appId = my.gadgets[moduleId].appId;
url += (url.indexOf('?') != url.length - 1 ? '&' : '') + 'appId=' + appId; url += '&appId=' + appId;
} }
if (opt_params) { if (opt_params) {
var paramStr = gadgets.json.stringify(opt_params); var paramStr = gadgets.json.stringify(opt_params);
if (paramStr.length > 0) { if (paramStr.length > 0) {
url += (url.indexOf('?') != url.length - 1 ? '&' : '') + 'appParams=' + encodeURIComponent(paramStr); url += '&appParams=' + encodeURIComponent(paramStr);
} }
} }
if (url && document.location.href.indexOf(url) == -1) { if (url && document.location.href.indexOf(url) == -1) {
@ -310,10 +374,9 @@ OrngGadgetService.prototype.requestNavigateTo = function(view, opt_params) {
} }
}; };
// OrngGadget //ORNGGadget
ORNGGadget = function(opt_params) {
OrngGadget = function(opt_params) { shindig.BaseIfrGadget.call(this, opt_params);
shindig.Gadget.call(this, opt_params);
this.debug = my.debug; this.debug = my.debug;
this.serverBase_ = my.openSocialURL + "/gadgets/"; this.serverBase_ = my.openSocialURL + "/gadgets/";
var gadget = this; var gadget = this;
@ -330,13 +393,13 @@ OrngGadget = function(opt_params) {
} }
}; };
OrngGadget.inherits(shindig.BaseIfrGadget); ORNGGadget.inherits(shindig.BaseIfrGadget);
OrngGadget.prototype.setMetadata = function(metadata) { ORNGGadget.prototype.setMetadata = function(metadata) {
this.metadata = metadata; this.metadata = metadata;
}; };
OrngGadget.prototype.hasFeature = function(feature) { ORNGGadget.prototype.hasFeature = function(feature) {
for (var i = 0; i < this.metadata.features.length; i++) { for (var i = 0; i < this.metadata.features.length; i++) {
if (this.metadata.features[i] == feature) { if (this.metadata.features[i] == feature) {
return true; return true;
@ -345,7 +408,7 @@ OrngGadget.prototype.hasFeature = function(feature) {
return false; return false;
}; };
OrngGadget.prototype.getAdditionalParams = function() { ORNGGadget.prototype.getAdditionalParams = function() {
var params = ''; var params = '';
for (var key in my.gadgets[this.id].additionalParams) { for (var key in my.gadgets[this.id].additionalParams) {
params += '&' + key + '=' + my.gadgets[this.id].additionalParams[key]; params += '&' + key + '=' + my.gadgets[this.id].additionalParams[key];
@ -353,75 +416,18 @@ OrngGadget.prototype.getAdditionalParams = function() {
return params; return params;
}; };
OrngGadget.prototype.finishRender = function(chrome) { ORNGGadget.prototype.getIframeUrl = function() {
window.frames[this.getIframeId()].location = this.getIframeUrl();
if (my.gadgets[this.id].start_closed) {
this.handleToggle();
}
else if (chrome) {
// set the gadget box width, and remember that we always render as open
chrome.style.width = (my.gadgets[this.id].open_width || 600) + 'px';
}
};
OrngGadget.prototype.getIframeUrl = function() {
var url = this.originalGetIframeUrl(); var url = this.originalGetIframeUrl();
return url.replace('REPLACE_THIS_VIEW', my.gadgets[this.id].view); return url.replace('REPLACE_THIS_VIEW', my.gadgets[this.id].view);
}; };
OrngGadget.prototype.handleToggle = function() { ORNGGadget.prototype.getTitleHtml = function(title) {
var gadgetIframe = document.getElementById(this.getIframeId()); return title ? title.replace(/&/g, '&amp;').replace(/</g, '&lt;') : 'Gagdget';
if (gadgetIframe) {
var gadgetContent = gadgetIframe.parentNode;
var gadgetImg = document.getElementById('gadgets-gadget-title-image-' + this.id);
if (gadgetContent.style.display) {
//OPEN
gadgetContent.parentNode.style.width = (my.gadgets[this.id].open_width || 600) + 'px';
gadgetContent.style.display = '';
gadgetImg.src = '/' + location.pathname.split('/')[1] + '/themes/wilma/images/green_minus_sign.gif';
// refresh if certain features require so
//if (this.hasFeature('dynamic-height')) {
if (my.gadgets[this.id].chrome_id == 'gadgets-search') {
this.refresh();
document.getElementById(this.getIframeId()).contentWindow.location.reload(true);
}
if (my.gadgets[this.id].view == 'home') {
// record in google analytics
_gaq.push(['_trackEvent', my.gadgets[this.id].name, 'OPEN_IN_EDIT', 'profile_edit_view']);
}
else {
// find out whose page we are on, if any
var userId = gadgets.util.getUrlParameters()['uri'] || document.URL.replace('/display/', '/individual/');
osapi.activities.create(
{ 'userId': userId,
'appId': my.gadgets[this.id].appId,
'activity': {'postedTime': new Date().getTime(), 'title': 'gadget viewed', 'body': my.gadgets[this.id].name + ' gadget was viewed' }
}).execute(function(response){});
// record in google analytics
_gaq.push(['_trackEvent', my.gadgets[this.id].name, 'OPEN']);
}
}
else {
//CLOSE
gadgetContent.parentNode.style.width = (my.gadgets[this.id].closed_width || 600) + 'px';
gadgetContent.style.display = 'none';
gadgetImg.src = '/' + location.pathname.split('/')[1] + '/themes/wilma/images/green_plus_sign.gif';
if (my.gadgets[this.id].view == 'home') {
// record in google analytics
_gaq.push(['_trackEvent', my.gadgets[this.id].name, 'CLOSE_IN_EDIT', 'profile_edit_view']);
}
else {
// record in google analytics
_gaq.push(['_trackEvent', my.gadgets[this.id].name, 'CLOSE']);
}
}
}
}; };
OrngGadget.prototype.getTitleBarContent = function(continuation) { ORNGGadget.prototype.getTitleBarContent = function(continuation) {
if (my.gadgets[this.id].view == 'canvas') { if (my.gadgets[this.id].view == 'canvas') {
document.getElementById("gadgets-title").innerHTML = (this.title ? this.title : 'Gadget'); ORNGGadgetService.setCanvasTitle(this.title);
continuation('<span class="gadgets-gadget-canvas-title"></span>'); continuation('<span class="gadgets-gadget-canvas-title"></span>');
} }
else { else {
@ -429,31 +435,143 @@ OrngGadget.prototype.getTitleBarContent = function(continuation) {
'<div id="' + this.cssClassTitleBar + '-' + this.id + '<div id="' + this.cssClassTitleBar + '-' + this.id +
'" class="' + this.cssClassTitleBar + '"><span class="' + '" class="' + this.cssClassTitleBar + '"><span class="' +
this.cssClassTitleButtonBar + '">' + this.cssClassTitleButtonBar + '">' +
'<a href="#" onclick="shindig.container.getGadget(' + this.id + '</span> <span id="' +
').handleToggle();return false;" class="' + this.cssClassTitleButton +
'"><img id="gadgets-gadget-title-image-' + this.id + '" src="/' + location.pathname.split('/')[1] + '/themes/wilma/images/green_minus_sign.gif"/></a></span> <span id="' +
this.getIframeId() + '_title" class="' + this.cssClassTitle + '">' + this.getIframeId() + '_title" class="' + this.cssClassTitle + '">' +
'<a href="#" onclick="shindig.container.getGadget(' + this.id + ').handleToggle();return false;">' + this.getTitleHtml(this.title) + '</span><span id="' +
(this.title ? this.title : 'Gadget') + '</a>' + '</span><span id="' +
this.getIframeId() + '_status" class="gadgets-gadget-status"></span></div>'); this.getIframeId() + '_status" class="gadgets-gadget-status"></span></div>');
} }
}; };
// OrngLayoutManager. Creates a FloatLeftLayoutManager for every chromeId in our gadgets ORNGGadget.prototype.finishRender = function(chrome) {
OrngLayoutManager = function() { window.frames[this.getIframeId()].location = this.getIframeUrl();
shindig.LayoutManager.call(this); if (chrome && this.width) {
// find out what chromeId's are being used, create a FloatLeftLayoutManager for each // set the gadget box width, and remember that we always render as open
this.layoutManagers = {}; chrome.style.width = this.width + 'px';
for (var moduleId = 0; moduleId < my.gadgets.length; moduleId++) { }
var chromeId = my.gadgets[moduleId].chrome_id; };
if (!this.layoutManagers[chromeId]) {
this.layoutManagers[chromeId] = new shindig.FloatLeftLayoutManager(chromeId); // ORNGToggleGadget
ORNGToggleGadget = function(opt_params) {
ORNGGadget.call(this, opt_params);
};
ORNGToggleGadget.inherits(ORNGGadget);
ORNGToggleGadget.prototype.handleToggle = function (track) {
var gadgetIframe = document.getElementById(this.getIframeId());
if (gadgetIframe) {
var gadgetContent = gadgetIframe.parentNode;
var gadgetImg = document.getElementById('gadgets-gadget-title-image-'
+ this.id);
if (gadgetContent.style.display) {
//OPEN
if (this.width) {
gadgetContent.parentNode.style.width = this.width + 'px';
}
gadgetContent.style.display = '';
gadgetImg.src = '/' + location.pathname.split('/')[1] + '/themes/wilma/images/green_minus_sign.gif'
// refresh if certain features require so
//if (this.hasFeature('dynamic-height')) {
if (my.gadgets[this.id].chrome_id == 'gadgets-search') {
this.refresh();
document.getElementById(this.getIframeId()).contentWindow.location
.reload(true);
}
if (my.gadgets[this.id].view == 'home') {
if (track) {
// record in google analytics
_gaq.push(['_trackEvent', my.gadgets[this.id].name,
'OPEN_IN_EDIT', 'profile_edit_view']);
}
} else {
// only do this for user centric activities
if (gadgets.util.getUrlParameters()['Person'] != undefined) {
osapi.activities
.create(
{
'userId': gadgets.util
.getUrlParameters()['Person'],
'appId': my.gadgets[this.id].appId,
'activity': {
'postedTime': new Date().getTime(),
'title': 'gadget was viewed',
'body': my.gadgets[this.id].name
+ ' gadget was viewed'
}
}).execute(function (response) {
});
}
if (track) {
// record in google analytics
_gaq.push(['_trackEvent', my.gadgets[this.id].name, 'OPEN']);
}
}
} else {
//CLOSE
if (this.closed_width) {
gadgetContent.parentNode.style.width = this.closed_width + 'px';
}
gadgetContent.style.display = 'none';
gadgetImg.src = '/' + location.pathname.split('/')[1] + '/themes/wilma/images/green_plus_sign.gif'
if (track) {
if (my.gadgets[this.id].view == 'home') {
// record in google analytics
_gaq.push(['_trackEvent', my.gadgets[this.id].name,
'CLOSE_IN_EDIT', 'profile_edit_view']);
} else {
// record in google analytics
_gaq.push(['_trackEvent', my.gadgets[this.id].name, 'CLOSE']);
}
}
} }
} }
}; };
OrngLayoutManager.inherits(shindig.LayoutManager); ORNGToggleGadget.prototype.getTitleHtml = function(title) {
return '<a href="#" onclick="shindig.container.getGadget('
OrngLayoutManager.prototype.getGadgetChrome = function(gadget) { + this.id + ').handleToggle(true);return false;">'
return this.layoutManagers[my.gadgets[gadget.id].chrome_id].getGadgetChrome(gadget); + (title ? title.replace(/&/g, '&amp;').replace(/</g, '&lt;') : 'Gadget') + '</a>';
}; };
ORNGToggleGadget.prototype.getTitleBarContent = function(continuation) {
if (my.gadgets[this.id].view == 'canvas') {
ORNGGadgetService.setCanvasTitle(title);
continuation('<span class="gadgets-gadget-canvas-title"></span>');
} else {
continuation('<div id="'
+ this.cssClassTitleBar
+ '-'
+ this.id
+ '" class="'
+ this.cssClassTitleBar
+ '"><span class="'
+ this.cssClassTitleButtonBar
+ '">'
+ '<a href="#" onclick="shindig.container.getGadget('
+ this.id
+ ').handleToggle(true);return false;" class="'
+ this.cssClassTitleButton
+ '"><img id="gadgets-gadget-title-image-'
+ this.id
+ '" src="/' + location.pathname.split('/')[1] + '/themes/wilma/images/green_minus_sign.gif"/></a></span> <span id="'
+ this.getIframeId() + '_title" class="' + this.cssClassTitle
+ '">' + this.getTitleHtml(this.title)
+ '</span><span id="' + this.getIframeId()
+ '_status" class="gadgets-gadget-status"></span></div>');
}
};
ORNGToggleGadget.prototype.finishRender = function(chrome) {
window.frames[this.getIframeId()].location = this.getIframeUrl();
if (this.start_closed) {
this.handleToggle(false);
}
else if (chrome && this.width) {
chrome.style.width = this.width + 'px';
}
};