Author: [email protected]
Date: Tue Jan 10 11:23:06 2012
New Revision: 1903
Log:
[AMDATUOPENSOCIAL-176] Fixed Permission denied error when switching themes
while external gadgets are rendered on the dashboard
Modified:
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/jsp/dashboard.js.jsp
Modified:
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/jsp/dashboard.js.jsp
==============================================================================
---
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/jsp/dashboard.js.jsp
(original)
+++
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/jsp/dashboard.js.jsp
Tue Jan 10 11:23:06 2012
@@ -31,33 +31,38 @@
onSelect: function() {
var cssLink = $("link.ui-theme:last").attr("href");
$.each($("iframe.gadgets-gadget"),function(idx, iframe) {
- setCSS(iframe,cssLink);
+ setCSS(iframe, cssLink);
});
}
});
function setCSS(iframe, cssLink) {
- // Add CSS link
- var oDoc = iframe.contentWindow || iframe.contentDocument;
- if (oDoc.document) {
- oDoc = oDoc.document;
- }
- var heads = oDoc.getElementsByTagName("head");
- if (heads.length > 0) {
- var link = oDoc.createElement("link");
- link.setAttribute("class", "ui-theme");
- link.setAttribute("rel", "stylesheet");
- link.setAttribute("href", cssLink);
-
- heads[0].appendChild(link);
-
- // Remove old CSS links
- var uithemes = $("link.ui-theme");
- if (uithemes.length > 1) {
- for (var i=1; i<uithemes.length;i++) {
- $($("link.ui-theme")[0]).remove();
+ try {
+ // Add CSS link
+ var oDoc = iframe.contentWindow || iframe.contentDocument;
+ if (oDoc.document) {
+ oDoc = oDoc.document;
+ }
+ var heads = oDoc.getElementsByTagName("head");
+ if (heads.length > 0) {
+ var link = oDoc.createElement("link");
+ link.setAttribute("class", "ui-theme");
+ link.setAttribute("rel", "stylesheet");
+ link.setAttribute("href", cssLink);
+
+ heads[0].appendChild(link);
+
+ // Remove old CSS links
+ var uithemes = $("link.ui-theme");
+ if (uithemes.length > 1) {
+ for (var i=1; i<uithemes.length;i++) {
+ $($("link.ui-theme")[0]).remove();
+ }
}
}
+ } catch(e) {
+ // A 'Permission denied' error will occur trying to update the head
+ // of external gadgets, as this violates the same origin policy.
}
}
_______________________________________________
Amdatu-commits mailing list
[email protected]
http://lists.amdatu.org/mailman/listinfo/amdatu-commits