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),
(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'),
(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`;
INSERT INTO `orng_app_views` (`appid`, `viewer_req`, `owner_req`, `page`, `view`, `closed_width`, `open_width`, `start_closed`, `chromeId`, `display_order`) VALUES
(100, NULL, NULL, 'search', NULL, 600, 600, 1, 'gadgets-search', NULL),
(101, NULL, 'R', 'individual', 'profile', 290, 600, 1, 'gadgets-view', 3),
(101, NULL, NULL, 'individual-EDIT-MODE', 'home', 700, 700, 1, 'gadgets-edit', NULL),
(102, NULL, 'R', 'individual', 'profile', 290, 600, 1, 'gadgets-view', 2),
(102, NULL, NULL, 'individual-EDIT-MODE', 'home', 700, 700, 1, 'gadgets-edit', NULL),
(103, NULL, NULL, 'individual-EDIT-MODE', 'home', 700, 700, 1, 'gadgets-edit', NULL),
(103, NULL, 'R', 'individual', 'profile', 290, 600, 0, 'gadgets-view', 1),
(104, 'U', NULL, 'search', 'small', 160, 160, 0, 'gadgets-tools', NULL),
(104, 'U', NULL, 'gadgetDetails', 'canvas', 700, 700, 0, 'gadgets-detail', NULL),
(104, 'U', NULL, 'SimilarPeople.aspx', 'small', 160, 160, 0, 'gadgets-tools', NULL),
(104, 'U', NULL, 'individual', 'small', 290, 290, 0, 'gadgets-view', NULL),
(104, 'U', NULL, 'CoAuthors.aspx', 'small', 160, 160, 0, 'gadgets-tools', NULL),
(106, NULL, NULL, 'individual-EDIT-MODE', 'home', 700, 700, 1, 'gadgets-edit', NULL);
INSERT INTO `orng_app_views` (`appid`, `viewer_req`, `owner_req`, `page`, `view`, `chromeId`, `opt_params`, `display_order`) VALUES
(100, NULL, NULL, 'search', NULL, 'gadgets-search', NULL, NULL),
(101, NULL, 'R', 'individual', 'profile', 'gadgets-view', '{''gadget_class'':''ORNGToggleGadget'', ''start_closed'':1, ''closed_width'':290}', 4),
(101, NULL, NULL, 'individual-EDIT-MODE', 'home', 'gadgets-edit', '{''gadget_class'':''ORNGToggleGadget'', ''start_closed'':1, ''closed_width'':700}', 4),
(102, NULL, 'R', 'individual', 'profile', 'gadgets-view', '{''gadget_class'':''ORNGToggleGadget'', ''start_closed'':1, ''closed_width'':290}', 3),
(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', 'gadgets-edit', '{''gadget_class'':''ORNGToggleGadget'', ''start_closed'':1, ''closed_width'':700}', NULL),
(103, NULL, 'R', 'individual', 'profile', 'gadgets-view', '{''gadget_class'':''ORNGToggleGadget'', ''start_closed'':0, ''closed_width'':290}', 1),
(104, 'U', NULL, 'search', 'small', 'gadgets-tools', NULL, NULL),
(104, 'U', NULL, 'gadgetDetails', 'canvas', 'gadgets-detail', NULL, NULL),
(104, 'U', NULL, 'individual', 'small', 'gadgets-view', NULL, NULL),
(106, NULL, NULL, 'individual-EDIT-MODE', 'home', 'gadgets-edit', '{''gadget_class'':''ORNGToggleGadget'', ''start_closed'':1, ''closed_width'':700}', NULL),
(112, NULL, 'R', 'individual', 'profile', 'gadgets-view', '{''gadget_class'':''ORNGToggleGadget'', ''start_closed'':0, ''closed_width'':290}', 2),
(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`
--
CREATE TABLE IF NOT EXISTS `orng_activity` (
DROP TABLE IF EXISTS `orng_activity`;
CREATE TABLE `orng_activity` (
`activityId` int(11) NOT NULL AUTO_INCREMENT,
`userId` varchar(255) default NULL,
`appId` int(11) default NULL,
@ -18,7 +19,8 @@ CREATE TABLE IF NOT EXISTS `orng_activity` (
-- 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,
`appId` int(11) NOT NULL,
`keyname` varchar(255) NOT NULL,
@ -34,7 +36,8 @@ CREATE TABLE IF NOT EXISTS `orng_appdata` (
-- 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,
`name` 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`
--
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,
`personId` varchar(255) 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`
--
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,
`viewer_req` char(1) default NULL,
`owner_req` char(1) default NULL,
`page` 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,
`display_order` int(11) default NULL
`display_order` int(11) default NULL,
`opt_params` varchar(255) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
@ -82,7 +85,8 @@ CREATE TABLE IF NOT EXISTS `orng_app_views` (
-- 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,
`senderId` 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 //
CREATE PROCEDURE orng_registerAppPerson (uid varchar(255), aid INT, v BOOL)
BEGIN
@ -131,7 +139,7 @@ END //
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
DELETE FROM orng_appdata WHERE userId = uid AND appId = aid and keyname = kn;
-- if keyname is VISIBLE, do more

View file

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

Binary file not shown.

View file

@ -37,7 +37,7 @@ public class GadgetSpec {
ResultSet rset = null;
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;
conn = ds.getConnection();
stmt = conn.createStatement();
@ -47,9 +47,8 @@ public class GadgetSpec {
rset.getString(1),
new GadgetViewRequirements(rset.getString(1), rset
.getString(2), rset.getString(3), rset
.getString(4), rset.getInt(5), rset
.getInt(6), rset.getBoolean(7), rset
.getString(8), rset.getInt(9)));
.getString(4), rset.getString(5), rset
.getString(6), rset.getInt(7)));
}
} finally {
try {

View file

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

View file

@ -353,15 +353,13 @@ public class OpenSocialManager {
public String getGadgetJavascript() {
String lineSeparator = System.getProperty("line.separator");
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
+ "this.name = name;" + lineSeparator + "this.url = url;"
+ lineSeparator + "this.secureToken = secureToken;"
+ lineSeparator + "this.view = view || 'default';"
+ lineSeparator + "this.closed_width = closed_width;"
+ lineSeparator + "this.open_width = open_width;"
+ lineSeparator + "this.start_closed = start_closed;"
+ lineSeparator + "this.chrome_id = chrome_id;" + lineSeparator
+ lineSeparator + "this.chrome_id = chrome_id;"
+ lineSeparator + "this.opt_params = opt_params;" + lineSeparator
+ "this.visible_scope = visible_scope;" + lineSeparator + "};"
+ lineSeparator + "my.pubsubData = {};" + lineSeparator;
for (String key : getPubsubData().keySet()) {
@ -377,10 +375,7 @@ public class OpenSocialManager {
gadgetScriptText += "new my.gadgetSpec(" + gadget.getAppId() + ",'"
+ gadget.getName() + "','" + gadget.getGadgetURL() + "','"
+ gadget.getSecurityToken() + "','" + gadget.getView()
+ "'," + gadget.getClosedWidth() + ","
+ gadget.getOpenWidth() + ","
+ (gadget.getStartClosed() ? "1" : "0") + ",'"
+ gadget.getChromeId() + "','"
+ "','" + gadget.getChromeId() + "'," + gadget.getOptParams() + ",'"
+ gadget.getGadgetSpec().getVisibleScope() + "'), ";
}
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() {
GadgetViewRequirements reqs = getGadgetViewRequirements();
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 {
return "~/gadget?appId=" + getAppId() + "&Person="
+ 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]);
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') {
// do nothing, no need to alert
}
@ -222,23 +225,31 @@ my.requestGadgetMetaData = function(view, opt_callback) {
my.renderableGadgets = [];
my.generateGadgets = function(metadata) {
my.generateGadgets = function (metadata) {
// put them in moduleId order
for (var i = 0; i < metadata.gadgets.length; i++) {
var moduleId = metadata.gadgets[i].moduleId;
// Notes by Eric. Not sure if I should have to calculate this myself, but I will.
var height = metadata.gadgets[i].height;
var width = metadata.gadgets[i].width;
var viewPrefs = metadata.gadgets[i].views[my.gadgets[moduleId].view];
if (viewPrefs) {
height = viewPrefs.preferredHeight || height;
width = viewPrefs.preferredWidth || width;
}
my.renderableGadgets[moduleId] = shindig.container.createGadget({'specUrl': metadata.gadgets[i].url, 'secureToken': my.gadgets[moduleId].secureToken,
'title': metadata.gadgets[i].title, 'userPrefs': metadata.gadgets[i].userPrefs,
'height': height, 'width': width, 'debug': my.debug});
// set the metadata for easy access
my.renderableGadgets[moduleId].setMetadata(metadata.gadgets[i]);
var moduleId = metadata.gadgets[i].moduleId;
// Notes by Eric. Not sure if I should have to calculate this myself, but I will.
var height = metadata.gadgets[i].height;
var width = metadata.gadgets[i].width;
var viewPrefs = metadata.gadgets[i].views[my.gadgets[moduleId].view];
if (viewPrefs) {
height = viewPrefs.preferredHeight || height;
width = viewPrefs.preferredWidth || width;
}
var opt_params = { 'specUrl': metadata.gadgets[i].url, 'secureToken': my.gadgets[moduleId].secureToken,
'title': metadata.gadgets[i].title, 'userPrefs': metadata.gadgets[i].userPrefs,
'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
my.renderableGadgets[moduleId].setMetadata(metadata.gadgets[i]);
}
// this will be called multiple times, only render when all gadgets have been processed
var ready = my.renderableGadgets.length == my.gadgets.length;
@ -249,21 +260,25 @@ my.generateGadgets = function(metadata) {
}
if (ready) {
shindig.container.addGadgets(my.renderableGadgets );
shindig.container.addGadgets(my.renderableGadgets);
shindig.container.renderGadgets();
}
};
my.init = function() {
shindig.container.gadgetClass = OrngGadget;
shindig.container.layoutManager = new OrngLayoutManager();
shindig.container.setNoCache(my.noCache);
shindig.container.gadgetService = new OrngGadgetService();
// overwrite this RPC function. Do it at this level so that rpc.f (this.f) is accessible for getting module ID
// gadgets.rpc.register('requestNavigateTo', doProfilesNavigation);
shindig.container = new ORNGContainer();
// 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.gadgetService = new ORNGGadgetService();
shindig.container.layoutManager = new ORNGLayoutManager();
// do multiple times as needed if we have multiple views
shindig.container.setNoCache(my.noCache);
// since we render multiple views, we need to do somethign fancy by swapping out this value in getIframeUrl
shindig.container.setView('REPLACE_THIS_VIEW');
// do multiple times as needed if we have multiple views
// find out what views are being used and call requestGadgetMetaData for each one
var views = {};
for (var moduleId = 0; moduleId < my.gadgets.length; moduleId++) {
@ -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);
};
OrngGadgetService.inherits(shindig.IfrGadgetService);
ORNGGadgetService.inherits(shindig.IfrGadgetService);
OrngGadgetService.prototype.requestNavigateTo = function(view, opt_params) {
var viewConfig = gadgets.config.get('views')[view];
var url = '/' + location.pathname.split('/')[1] + '/' + viewConfig.urlTemplate;
ORNGGadgetService.prototype.setTitle = function (title) {
var moduleId = shindig.container.gadgetService.getGadgetIdFromModuleId(this.f);
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);
// remove appId if present
url = my.removeParameterFromURL(url, 'appId');
// Add appId if isOnlyVisible is TRUE for this view
if (viewConfig.isOnlyVisible) {
// Add appId if the URL Template begins with the word 'Gadget'
if (urlTemplate.indexOf('Gadget') == 0) {
var moduleId = shindig.container.gadgetService.getGadgetIdFromModuleId(this.f);
var appId = my.gadgets[moduleId].appId;
url += (url.indexOf('?') != url.length - 1 ? '&' : '') + 'appId=' + appId;
url += '&appId=' + appId;
}
if (opt_params) {
var paramStr = gadgets.json.stringify(opt_params);
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) {
@ -310,10 +374,9 @@ OrngGadgetService.prototype.requestNavigateTo = function(view, opt_params) {
}
};
// OrngGadget
OrngGadget = function(opt_params) {
shindig.Gadget.call(this, opt_params);
//ORNGGadget
ORNGGadget = function(opt_params) {
shindig.BaseIfrGadget.call(this, opt_params);
this.debug = my.debug;
this.serverBase_ = my.openSocialURL + "/gadgets/";
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;
};
OrngGadget.prototype.hasFeature = function(feature) {
ORNGGadget.prototype.hasFeature = function(feature) {
for (var i = 0; i < this.metadata.features.length; i++) {
if (this.metadata.features[i] == feature) {
return true;
@ -345,7 +408,7 @@ OrngGadget.prototype.hasFeature = function(feature) {
return false;
};
OrngGadget.prototype.getAdditionalParams = function() {
ORNGGadget.prototype.getAdditionalParams = function() {
var params = '';
for (var key in my.gadgets[this.id].additionalParams) {
params += '&' + key + '=' + my.gadgets[this.id].additionalParams[key];
@ -353,107 +416,162 @@ OrngGadget.prototype.getAdditionalParams = function() {
return params;
};
OrngGadget.prototype.finishRender = function(chrome) {
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() {
ORNGGadget.prototype.getIframeUrl = function() {
var url = this.originalGetIframeUrl();
return url.replace('REPLACE_THIS_VIEW', my.gadgets[this.id].view);
};
OrngGadget.prototype.handleToggle = function() {
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
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);
}
ORNGGadget.prototype.getTitleHtml = function(title) {
return title ? title.replace(/&/g, '&amp;').replace(/</g, '&lt;') : 'Gagdget';
};
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']);
ORNGGadget.prototype.getTitleBarContent = function(continuation) {
if (my.gadgets[this.id].view == 'canvas') {
ORNGGadgetService.setCanvasTitle(this.title);
continuation('<span class="gadgets-gadget-canvas-title"></span>');
}
else {
continuation(
'<div id="' + this.cssClassTitleBar + '-' + this.id +
'" class="' + this.cssClassTitleBar + '"><span class="' +
this.cssClassTitleButtonBar + '">' +
'</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>');
}
};
ORNGGadget.prototype.finishRender = function(chrome) {
window.frames[this.getIframeId()].location = this.getIframeUrl();
if (chrome && this.width) {
// set the gadget box width, and remember that we always render as open
chrome.style.width = this.width + 'px';
}
};
// 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']);
}
}
}
}
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) {
if (my.gadgets[this.id].view == 'canvas') {
document.getElementById("gadgets-title").innerHTML = (this.title ? this.title : 'Gadget');
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();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 + '">' +
'<a href="#" onclick="shindig.container.getGadget(' + this.id + ').handleToggle();return false;">' +
(this.title ? this.title : 'Gadget') + '</a>' + '</span><span id="' +
this.getIframeId() + '_status" class="gadgets-gadget-status"></span></div>');
}
ORNGToggleGadget.prototype.getTitleHtml = function(title) {
return '<a href="#" onclick="shindig.container.getGadget('
+ this.id + ').handleToggle(true);return false;">'
+ (title ? title.replace(/&/g, '&amp;').replace(/</g, '&lt;') : 'Gadget') + '</a>';
};
// OrngLayoutManager. Creates a FloatLeftLayoutManager for every chromeId in our gadgets
OrngLayoutManager = function() {
shindig.LayoutManager.call(this);
// find out what chromeId's are being used, create a FloatLeftLayoutManager for each
this.layoutManagers = {};
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.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>');
}
};
OrngLayoutManager.inherits(shindig.LayoutManager);
OrngLayoutManager.prototype.getGadgetChrome = function(gadget) {
return this.layoutManagers[my.gadgets[gadget.id].chrome_id].getGadgetChrome(gadget);
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';
}
};