1 function equalWidths ( secondEl, firstEl) {
2 secondEl.css('width',firstEl.outerWidth() );
7 $(document).ready(function(){
13 var PROFILE_URL = "https://accounts.cloud.grnet.gr";
15 // cookie plugin https://raw.github.com/carhartl/jquery-cookie/master/jquery.cookie.js
16 // * Copyright (c) 2010 Klaus Hartl, @carhartl
17 // * Dual licensed under the MIT and GPL licenses
18 var cookie=function(key,value,options){if(arguments.length>1&&(!/Object/.test(Object.prototype.toString.call(value))||value===null||value===undefined)){options=$.extend({},options);if(value===null||value===undefined){options.expires=-1}if(typeof options.expires==='number'){var days=options.expires,t=options.expires=new Date();t.setDate(t.getDate()+days)}value=String(value);return(document.cookie=[encodeURIComponent(key),'=',options.raw?value:encodeURIComponent(value),options.expires?'; expires='+options.expires.toUTCString():'',options.path?'; path='+options.path:'',options.domain?'; domain='+options.domain:'',options.secure?'; secure':''].join(''))}options=value||{};var decode=options.raw?function(s){return s}:decodeURIComponent;var pairs=document.cookie.split('; ');for(var i=0,pair;pair=pairs[i]&&pairs[i].split('=');i++){if(decode(pair[0])===key)return decode(pair[1]||'')}return null};
20 var ACTIVE_MENU = window.CLOUDBAR_ACTIVE_SERVICE || 'cloud';
21 var USER_DATA = window.CLOUDBAR_USER_DATA || {'user': 'Not logged in', 'logged_in': false};
22 var COOKIE_NAME = window.CLOUDBAR_COOKIE_NAME || '_pithos2_a';
24 var cssloc = window.CLOUDBAR_LOCATION || "http://127.0.0.1:8989/";
27 var css = $("<link />");
28 css.attr({rel:'stylesheet', type:'text/css', href:cssloc + 'cloudbar.css'});
29 $("head").append(css);
32 var font_url = 'http://fonts.googleapis.com/css?family=Didact+Gothic&subset=latin,greek,greek-ext';
33 var css_font = $("<link />");
34 css_font.attr({rel:'stylesheet', type:'text/css', href:font_url});
35 $("head").append(css_font);
37 // load service specific css
38 var SKIP_ADDITIONAL_CSS = window.SKIP_ADDITIONAL_CSS == undefined ? false : window.SKIP_ADDITIONAL_CSS;
40 if (!SKIP_ADDITIONAL_CSS) {
41 var css = $("<link />");
42 css.attr({rel:'stylesheet', type:'text/css', href:cssloc + 'service_' + ACTIVE_MENU + '.css'});
43 $("head").append(css);
47 var bar = $('<div class="cloudbar servicesbar clearfix"></div>');
48 var services = $('<ul class="services"></ul>');
49 var profile = $('<div class="profile"></div>');
51 var get_services_url = window.GET_SERVICES_URL || window.CLOUDBAR_SERVICES;
53 // create services links and set the active class to the current service
54 $.getJSON(get_services_url + "?callback=?", function(data) {
55 $.each(data, function(i, el){
59 slink.append($('<img src="'+cssloc+el.icon+'"/>'));
60 slink.addClass("with-icon");
64 slink.attr('href', el.url);
65 slink.attr('title', el.name);
68 if (el.id == ACTIVE_MENU || el.name == ACTIVE_MENU) {
69 sli.addClass("active");
74 // create profile links
75 var user = $('<div class="user"></div>');
76 if (ACTIVE_MENU == "accounts") { user.addClass("hover active")}
77 var username = $('<a href="#"></a>');
78 var usermenu = $("<ul>");
79 var get_menu_url = (window.GET_MENU_URL || window.CLOUDBAR_MENU) + '?callback=?&location=' + window.location.toString();
81 $.getJSON(get_menu_url, function(data) {
82 $.each(data, function(i,el) {
84 username.html('<span>'+el.name+'</span>');
85 username.attr('href', el.url);
86 user.removeClass('full');
88 var link = $("<a />");
90 link.attr({href:el.url});
94 user.addClass('full');
99 //profile.filter(".user a").attr("href",
100 //profile.find("li a").get(0).attr("href"))
102 user.append(username);
103 user.append(usermenu);
104 profile.append(user);
105 bar.append(profile).append(services);
109 var firstlink = profile.find("ul li:first-child a").attr("href");
110 profile.find(".user > a").attr("href", firstlink);
113 user.hover(function(){$(this).addClass("hover")}, function(){$(this).removeClass("hover")});
114 $('html').live('click', function(e){
115 $('.cloudbar .profile .full>a').removeClass('open');
116 $('.cloudbar .profile .full>a').siblings('ul').hide();
120 $('.cloudbar .profile .full>a').live('click', function(e){
124 equalWidths ( $('.cloudbar .profile ul'), $('.cloudbar .profile'));
125 $(this).siblings('ul').toggle();
126 $(this).toggleClass('open');
133 $(window).resize(function() {
134 equalWidths ( $('.cloudbar .profile ul'), $('.cloudbar .profile'));