Author: [email protected]
Date: Tue Jan 17 16:39:36 2012
New Revision: 1921
Log:
[AMDATUOPENSOCIAL-178] Fixed invoking updateCSS from the dashboard framework
instead of each individual gadget, needing to load the the css_cookie.js which
is not available anymore after the aggregation of .js files
Modified:
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/static/js/css_cookie.js
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/static/js/dashboard.js
trunk/amdatu-opensocial/opensocial-shindig/src/main/resources/features/shindig.container/shindig-container.js
Modified:
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/static/js/css_cookie.js
==============================================================================
---
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/static/js/css_cookie.js
(original)
+++
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/static/js/css_cookie.js
Tue Jan 17 16:39:36 2012
@@ -1,23 +1,24 @@
-function updateCSS() {
- var theme = $.cookie("jquery-ui-theme");
+function updateCSS(ifrDoc) {
+ var theme = getCSSCookie(ifrDoc);
var cssLink =
"../../dashboard/static/themes/start/jquery-ui-1.8.16.custom.css";
if (theme) {
cssLink = cookieMap[theme.replace(" ","_")];
}
// Update existing CSS links
- var uithemes = $("link.ui-theme");
+ var head = ifrDoc.getElementsByTagName("head")[0];
+ var uithemes = $(head).find("link.ui-theme");
if (uithemes.length > 0) {
for (var i=0; i<uithemes.length;i++) {
- $("link.ui-theme")[i].setAttribute("href", cssLink);
+ uithemes[i].setAttribute("href", cssLink);
}
} else {
// Append new CSS link
- var link = document.createElement("link");
+ var link = ifrDoc.createElement("link");
link.setAttribute("class","ui-theme");
link.setAttribute("rel","stylesheet");
link.setAttribute("href",cssLink);
- document.getElementsByTagName("head")[0].appendChild(link);
+ ifrDoc.getElementsByTagName("head")[0].appendChild(link);
}
}
@@ -56,11 +57,12 @@
* http://www.gnu.org/licenses/gpl.html
*
*/
-jQuery.cookie = function(name) {
+function getCSSCookie(ifrDoc) {
// get cookie
+ var name = "jquery-ui-theme";
var cookieValue = null;
- if (document.cookie && document.cookie != '') {
- var cookies = document.cookie.split(';');
+ if (ifrDoc.cookie && ifrDoc.cookie != '') {
+ var cookies = ifrDoc.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
@@ -72,3 +74,4 @@
}
return cookieValue;
};
+
Modified:
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/static/js/dashboard.js
==============================================================================
---
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/static/js/dashboard.js
(original)
+++
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/static/js/dashboard.js
Tue Jan 17 16:39:36 2012
@@ -55,9 +55,9 @@
var dashboard = $('#dashboard').dashboard({
debuglevel:1,
layoutClass: 'layout',
- loadingHtml: '<div class="loading"><img alt="Loading, please wait"
src="' + staticDbPath + '"/img/loading.gif" /><p>Loading</p></div>',
+ loadingHtml: '<div class="loading"><img alt="Loading, please wait"
src="' + staticDbPath + '/img/loading.gif" /><p>Loading</p></div>',
json_data : {
- url: contextPath + "/rest/dashboards/db_dashboard"
+ url: contextPath + "/rest/dashboards/dashboard"
},
addWidgetSettings: {
widgetDirectoryUrl: contextPath + "/rest/gadgetstore/categories"
@@ -135,6 +135,7 @@
my.init();
my.renderGadget = function(widget) {
+
// Override the default gadget constructor, since that sets a
serverBase_ without the context path
// See
http://pillvin.blogspot.com/2008/12/deploying-shindig-in-non-root-context.html
widget.WidgetIfrGadget = function(opt_params) {
@@ -142,6 +143,7 @@
this.serverBase_ = contextPath + '/gadgets/'; // default gadget server
this.queryIfrGadgetType_();
};
+
widget.WidgetIfrGadget.inherits(shindig.BaseIfrGadget);
shindig.IfrContainer.prototype.gadgetClass = widget.WidgetIfrGadget;
@@ -153,6 +155,9 @@
shindig.container.addGadget(gadget);
shindig.container.renderGadget(gadget);
+ // Update the CSS as soon as the iframe loads
+ my.updateCSS(widget);
+
// Override the RPC call set_title to set the title in our custom
titlebar
// instead of the default Shindig one, which is hidden
gadgets.rpc.register('set_title', function(newTitle) {
@@ -164,6 +169,21 @@
}
};
+ my.updateCSS = function(widgetParent) {
+ var widget = widgetParent.element;
+ var ifr = $(widget).find("iframe")[0];
+
+ var originalOnLoad = ifr.onload;
+ if (originalOnLoad) {
+ ifr.onload = "";
+ $(ifr).load(function() {
+ var ifrDocument = $(widget).find("iframe")[0].contentDocument;
+ updateCSS(ifrDocument);
+ originalOnLoad();
+ });
+ }
+ }
+
$('.widget').live('widgetShow',function(e, obj){
if (!obj.widget.loaded) {
obj.widget.loaded = true;
@@ -250,7 +270,6 @@
return false;
});
-
dashboard.element.live('dashboardAddWidget',function(e, obj){
var widget = obj.widget;
Modified:
trunk/amdatu-opensocial/opensocial-shindig/src/main/resources/features/shindig.container/shindig-container.js
==============================================================================
---
trunk/amdatu-opensocial/opensocial-shindig/src/main/resources/features/shindig.container/shindig-container.js
(original)
+++
trunk/amdatu-opensocial/opensocial-shindig/src/main/resources/features/shindig.container/shindig-container.js
Tue Jan 17 16:39:36 2012
@@ -818,12 +818,13 @@
gadgets.rpc.setAuthToken(iframeId, this.rpcToken);
// This onload function hides the 'loading' icon and displays the iframe,
when loaded
- var onload = "var iframe=document.getElementById('" + iframeId + "');" +
- "iframe.style.visibility='';" +
- "iframe.style.display='';" +
+ var onload = "" +
+ "var iframe=document.getElementById('" + iframeId + "');" +
"var loading=document.getElementById('" + iframeId + "_loading');" +
"loading.style.visibility='hidden';" +
- "loading.style.display='none';";
+ "loading.style.display='none';" +
+ "iframe.style.visibility='';" +
+ "iframe.style.display='';";
continuation('<div class="' + this.cssClassGadgetContent + '"><iframe
id="' +
iframeId + '" name="' + iframeId + '" class="' + this.cssClassGadget +
_______________________________________________
Amdatu-commits mailing list
[email protected]
http://lists.amdatu.org/mailman/listinfo/amdatu-commits