Author: [email protected]
Date: Tue Jan 10 09:54:08 2012
New Revision: 1900
Log:
[AMDATUOPENSOCIAL-176] Fixed initial theme loading in IE.
Modified:
trunk/amdatu-opensocial/dashboard-plugin/src/main/resources/static/js/themeroller.js
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/jsp/dashboard.js.jsp
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/static/js/css_cookie.js
Modified:
trunk/amdatu-opensocial/dashboard-plugin/src/main/resources/static/js/themeroller.js
==============================================================================
---
trunk/amdatu-opensocial/dashboard-plugin/src/main/resources/static/js/themeroller.js
(original)
+++
trunk/amdatu-opensocial/dashboard-plugin/src/main/resources/static/js/themeroller.js
Tue Jan 10 09:54:08 2012
@@ -95,8 +95,11 @@
}
} else {
// Append new CSS link
- var cssLink = $('<link href="'+locStr+'" type="text/css"
rel="Stylesheet" class="ui-theme" />');
+ var cssLink = $('<link href="'+locStr+'" rel="stylesheet"
class="ui-theme" />');
$("head").append(cssLink);
+
+ // NB: this is only necessary for IE, otherwise the new CSS link has no
effect
+ $("link.ui-theme")[0].setAttribute("href", locStr);
}
}
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 09:54:08 2012
@@ -38,18 +38,25 @@
function setCSS(iframe, cssLink) {
// Add CSS link
- var link = iframe.contentDocument.createElement("link");
- link.setAttribute("class","ui-theme");
- link.setAttribute("rel","stylesheet");
- link.setAttribute("href",cssLink);
-
- iframe.contentDocument.getElementsByTagName("head")[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();
+ 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();
+ }
}
}
}
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 10 09:54:08 2012
@@ -1,20 +1,23 @@
function updateCSS() {
var theme = $.cookie("jquery-ui-theme");
- var cssLink =
"../../dashboard/static/themes/redmond/jquery-ui-1.8.16.custom.css";
+ var cssLink =
"../../dashboard/static/themes/start/jquery-ui-1.8.16.custom.css";
if (theme) {
cssLink = cookieMap[theme.replace(" ","_")];
}
- // Append CSS link
- link = $('<link href="'+cssLink+'" type="text/css" rel="Stylesheet"
class="ui-theme" />');
- $("head").append(link);
-
- // Remove old CSS links
+ // Update existing CSS links
var uithemes = $("link.ui-theme");
- if (uithemes.length > 1) {
- for (var i=1; i<uithemes.length;i++) {
- $("link.ui-theme")[0].remove();
+ if (uithemes.length > 0) {
+ for (var i=0; i<uithemes.length;i++) {
+ $("link.ui-theme")[i].setAttribute("href", cssLink);
}
+ } else {
+ // Append new CSS link
+ var link = document.createElement("link");
+ link.setAttribute("class","ui-theme");
+ link.setAttribute("rel","stylesheet");
+ link.setAttribute("href",cssLink);
+ document.getElementsByTagName("head")[0].appendChild(link);
}
}
_______________________________________________
Amdatu-commits mailing list
[email protected]
http://lists.amdatu.org/mailman/listinfo/amdatu-commits