You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rave.apache.org by ja...@apache.org on 2012/03/12 19:43:46 UTC
svn commit: r1299779 -
/incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave_wookie.js
Author: jasha
Date: Mon Mar 12 18:43:46 2012
New Revision: 1299779
URL: http://svn.apache.org/viewvc?rev=1299779&view=rev
Log:
RAVE-485. W3C Widgets sometimes render outside of container. Patch by Paul Sharples (psharples).
Modified:
incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave_wookie.js
Modified: incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave_wookie.js
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave_wookie.js?rev=1299779&r1=1299778&r2=1299779&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave_wookie.js (original)
+++ incubator/rave/trunk/rave-portal-resources/src/main/webapp/script/rave_wookie.js Mon Mar 12 18:43:46 2012
@@ -21,13 +21,14 @@ rave.wookie = rave.wookie || (function()
var WIDGET_TYPE = "W3C";
var OFFSET = 10;
var MIN_HEIGHT = 250;
-
+ // keep this value so we can show the widget in the maximize view even when its collapsed
+ var userCollapsed;
var container;
-
+
function validateAndRenderWidget(widget){
-
+ userCollapsed = widget.collapsed;
var widgetBodyElement = document.getElementById(["widget-", widget.regionWidgetId, "-body"].join(""));
-
+
var widgetIframe = document.createElement("iframe");
if (widget.height){
@@ -35,13 +36,12 @@ rave.wookie = rave.wookie || (function()
widgetIframe.setAttribute("min-height",MIN_HEIGHT+"px");
} else {
widgetIframe.setAttribute("height",MIN_HEIGHT+"px");
- widgetIframe.setAttribute("min-height",MIN_HEIGHT+"px");
- }
- if (widget.width) {
- widgetIframe.setAttribute("style","width: 100%; min-width: "+widget.width);
- } else {
- widgetIframe.setAttribute("style","width: 100%");
+ widgetIframe.setAttribute("min-height",MIN_HEIGHT+"px");
}
+ // Rendering the widgets width causes the w3c widget to appear outside of the
+ // container object in some browsers. Setting to 100% seems to fix this.
+ // (there is something similar in the rave_opensocial.js file)
+ widgetIframe.setAttribute("style","width: 100%");
widgetIframe.setAttribute("src",widget.widgetUrl);
widgetIframe.setAttribute("scroll","no");
widgetIframe.setAttribute("frameborder","0");
@@ -50,6 +50,30 @@ rave.wookie = rave.wookie || (function()
widgetIframe.setAttribute("marginheight","0");
widgetIframe.setAttribute("marginwidth","0");
widgetBodyElement.appendChild(widgetIframe);
+ // collapse/restore functions
+ widget.collapse = function() {
+ $(widgetIframe).hide();
+ };
+ widget.restore = function() {
+ $(widgetIframe).show();
+ };
+ widget.maximize = function() {
+ // always display the widget in canvas view even if it currently collapsed
+ if (widget.collapsed){
+ userCollapsed = true;
+ $(widgetIframe).show();
+ }
+ };
+ widget.minimize = function() {
+ if (widget.collapsed){
+ userCollapsed = false;
+ $(widgetIframe).hide();
+ }
+ };
+ // if in the collapsed state, hide the layer
+ if (widget.collapsed){
+ $(widgetIframe).hide();
+ }
}
/**
@@ -74,4 +98,4 @@ rave.wookie = rave.wookie || (function()
})();
//Register the widget provider with Rave
-rave.registerProvider(rave.wookie);
\ No newline at end of file
+rave.registerProvider(rave.wookie);