Merge remote-tracking branch 'origin/newstyles' into newstyles
[astakos] / snf-astakos-app / astakos / im / static / im / cloudbar / cloudbar.js
index 43f29dc..4949de1 100644 (file)
@@ -32,8 +32,8 @@ $(document).ready(function(){
     }
 
     var root = $('body');
-    var bar = $('<div class="servicesbar"></div>');
-    var services = $('<div class="services"></div>');
+    var bar = $('<div class="cloudbar clearfix"></div>');
+    var services = $('<ul class="services"></ul>');
     var profile = $('<div class="profile"></div>');
     
     var get_services_url = window.GET_SERVICES_URL || window.CLOUDBAR_SERVICES;
@@ -41,23 +41,27 @@ $(document).ready(function(){
     // create services links and set the active class to the current service
     $.getJSON(get_services_url + "?callback=?", function(data) {
             $.each(data, function(i, el){
+            var sli = $("<li>");
             var slink = $("<a>");
             if (el.icon) {
                 slink.append($('<img src="'+cssloc+el.icon+'"/>'));
+                slink.addClass("with-icon");
             } else {
                 slink.text(el.name);
             }
             slink.attr('href', el.url);
             slink.attr('title', el.name);
-            services.append(slink);
-            if (el.id == ACTIVE_MENU) {
-                slink.addClass("active");
+            sli.append(slink);
+            services.append(sli);
+            if (el.id == ACTIVE_MENU || el.name == ACTIVE_MENU) {
+                sli.addClass("active");
             }
         });
       });
     
     // create profile links
     var user = $('<div class="user"></div>');    
+    if (ACTIVE_MENU == "accounts") { user.addClass("hover active")}
     var username = $('<a href="#"></a>');
     var usermenu = $("<ul>");
     var get_menu_url = (window.GET_MENU_URL || window.CLOUDBAR_MENU) + '?callback=?&location=' + window.location.toString();
@@ -65,8 +69,9 @@ $(document).ready(function(){
     $.getJSON(get_menu_url, function(data) {
         $.each(data, function(i,el) {
             if (i == 0){
-                username.text(el.name);
+                username.html('<span>'+el.name+'</span>');
                 username.attr('href', el.url);
+                user.removeClass('full');
             }else{
                 var link = $("<a />");
                 link.text(el.name);
@@ -74,6 +79,7 @@ $(document).ready(function(){
                 var li = $("<li />");
                 li.append(link);
                 usermenu.append(li);
+                user.addClass('full');
             }
         });
     });
@@ -84,10 +90,35 @@ $(document).ready(function(){
     user.append(username);
     user.append(usermenu);
     profile.append(user);
-    bar.append(services).append(profile);
+    bar.append(profile).append(services);
     
 
     root.prepend(bar);
     var firstlink = profile.find("ul li:first-child a").attr("href");
     profile.find(".user > a").attr("href", firstlink);
+
+    // ie fix
+    user.hover(function(){$(this).addClass("hover")}, function(){$(this).removeClass("hover")});
+    
+    /*$('.cloudbar .profile ul').mouseover(function(){
+        $(this).parents('.profile').css('backgroundColor','#000');
+        
+    });
+     $('.cloudbar .profile ul').mouseout(function(){
+        $(this).parents('.profile').css('backgroundColor','#01A1AE');
+        
+    });*/
+   $('.cloudbar .profile .full>a').live('click', function(e){
+               e.preventDefault();
+        $('.cloudbar .profile ul').css('width',$('.profile').outerWidth() );
+               $(this).siblings('ul').toggle();
+               $(this).toggleClass('open');
+               
+   });
+    
+    
+
+    
+    
+    
 });