Author: carlucci
Date: Fri Oct 5 14:05:53 2012
New Revision: 1394534
URL: http://svn.apache.org/viewvc?rev=1394534&view=rev
Log:
RAVE-808: Add ability to hide / show a widget. Patch supplied by Erin Noe-Payne
Modified:
rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave.js
rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave_opensocial.js
Modified: rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave.js
URL:
http://svn.apache.org/viewvc/rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave.js?rev=1394534&r1=1394533&r2=1394534&view=diff
==============================================================================
--- rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave.js
(original)
+++ rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave.js Fri
Oct 5 14:05:53 2012
@@ -437,6 +437,20 @@ var rave = rave || (function () {
}
}
+ function hideAction(args) {
+ var regionWidgetId = args.data.id;
+ var widget = rave.getRegionWidgetById(regionWidgetId);
+
+ widget.hide();
+ }
+
+ function showAction(args) {
+ var regionWidgetId = args.data.id;
+ var widget = rave.getRegionWidgetById(regionWidgetId);
+
+ widget.show();
+ }
+
function createPopup(popupType, prefs) {
var height = (prefs && prefs.preferredHeight);
var width = (prefs && prefs.preferredWidth);
@@ -880,6 +894,8 @@ var rave = rave || (function () {
toggleCollapseWidgetIcon:toggleCollapseWidgetIcon,
maximizeAction:maximizeAction,
minimizeAction:minimizeAction,
+ hideAction: hideAction,
+ showAction: showAction,
createPopup:createPopup,
destroyPopup:destroyPopup,
editPrefsAction:editPrefsAction,
@@ -1416,6 +1432,20 @@ var rave = rave || (function () {
*/
minimizeWidget:ui.minimizeAction,
+ /**
+ * Hide the widget and its chrome
+ *
+ * @param args the argument object
+ */
+ hideWidget: ui.hideAction,
+
+ /**
+ * Show the widget and its chrome
+ *
+ * @param args the argument object
+ */
+ showWidget: ui.showAction,
+
/***
* Create a new popup in the rave container
*
Modified:
rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave_opensocial.js
URL:
http://svn.apache.org/viewvc/rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave_opensocial.js?rev=1394534&r1=1394533&r2=1394534&view=diff
==============================================================================
---
rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave_opensocial.js
(original)
+++
rave/trunk/rave-portal-resources/src/main/webapp/static/script/rave_opensocial.js
Fri Oct 5 14:05:53 2012
@@ -79,6 +79,8 @@ rave.opensocial = rave.opensocial || (fu
container.rpcRegister('set_title', setTitle);
container.rpcRegister('requestNavigateTo', requestNavigateTo);
container.rpcRegister('set_pref', setPref);
+ container.rpcRegister('hideWidget', hideWidget);
+ container.rpcRegister('showWidget', showWidget);
}
function implementViews() {
@@ -167,6 +169,12 @@ rave.opensocial = rave.opensocial || (fu
gadget.restore = function () {
renderGadgetView(rave.opensocial.VIEW_NAMES.HOME,
rave.getRegionWidgetById(this.regionWidgetId));
};
+ gadget.hide = function(){
+
$(getGadgetIframeByWidgetId(this.regionWidgetId)).closest('.widget-wrapper').hide();
+ };
+ gadget.show = function() {
+
$(getGadgetIframeByWidgetId(this.regionWidgetId)).closest('.widget-wrapper').show();
+ };
gadget.savePreferences = function (userPrefs) {
this.userPrefs = userPrefs;
if(rave.isPageEditor()){
@@ -341,6 +349,25 @@ rave.opensocial = rave.opensocial || (fu
}
}
+
+ function hideWidget(args){
+ var widgetId =
rave.getObjectIdFromDomId(args.gs.getActiveSiteHolder().getElement().id);
+ var fnArgs = {};
+ fnArgs.data = {}
+ fnArgs.data.id = widgetId;
+
+ rave.hideWidget(fnArgs);
+ }
+
+ function showWidget(args){
+ var widgetId =
rave.getObjectIdFromDomId(args.gs.getActiveSiteHolder().getElement().id);
+ var fnArgs = {};
+ fnArgs.data = {}
+ fnArgs.data.id = widgetId;
+
+ rave.showWidget(fnArgs);
+ }
+
/**
* Re-renders the gadget in the requested view
*