Author: [email protected]
Date: Mon Jan  9 15:50:00 2012
New Revision: 1898

Log:
[AMDATUOPENSOCIAL-176] Theme switching didn't work properly in Chrome and FF 
either, fixed proper switching for those browsers. Still not working in IE 
though.

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
        Mon Jan  9 15:50:00 2012
@@ -87,11 +87,16 @@
 
   //function to append a new theme stylesheet with the new style changes
   function updateCSS(locStr){
+    // Append new CSS link
     var cssLink = $('<link href="'+locStr+'" type="text/css" rel="Stylesheet" 
class="ui-theme" />');
     $("head").append(cssLink);
 
-    if( $("link.ui-theme").size() > 3){
-      $("link.ui-theme:first").remove();
+    // 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/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
        Mon Jan  9 15:50:00 2012
@@ -37,17 +37,19 @@
   });
 
   function setCSS(iframe, cssLink) {
-    var heads = document.getElementsByTagName("head");
-    var uithemes = heads[0].getElementsByClassName("ui-theme");
-    if (uithemes.length > 0) {
-      uithemes[0].setAttribute("href",cssLink);
-    }
-    else {
-      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);
+    // 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();
+      }
     }
   }
 
@@ -165,14 +167,6 @@
           var titlebar = parent.find('.widgettitle');
           titlebar.html(newTitle);
         });
-
-        /*
-        var id = $("iframe.gadgets-gadget").size()-1;
-        $("#remote_iframe_"+id).load(function() {
-          alert("loaded!");
-          
setCSS($("iframe.gadgets-gadget:last"),$("link.ui-theme:last").attr("href")); 
// FIXME
-        });
-        */
       }
     };
 

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
     Mon Jan  9 15:50:00 2012
@@ -4,13 +4,17 @@
   if (theme) {
     cssLink = cookieMap[theme.replace(" ","_")];
   }
-  var link = $("link.ui-theme");
-  if (link.length > 0) {
-    link.attr("href",cssLink);
-  } 
-  else {
-    link = $('<link href="'+cssLink+'" type="text/css" rel="Stylesheet" 
class="ui-theme" />');
-    $("head").append(link);
+
+  // Append CSS link
+  link = $('<link href="'+cssLink+'" type="text/css" rel="Stylesheet" 
class="ui-theme" />');
+  $("head").append(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();
+    }
   }
 }
 
_______________________________________________
Amdatu-commits mailing list
[email protected]
http://lists.amdatu.org/mailman/listinfo/amdatu-commits

Reply via email to