Revision a697f671 ui/static/synnefo.js

b/ui/static/synnefo.js
2337 2337
function show_invitations() {
2338 2338

  
2339 2339
    handle_invitations = function(el) {
2340

  
2341
        // proper class to identify the overlay block
2340 2342
        el.addClass("invitations");
2343

  
2341 2344
        var cont = el;
2342 2345
        var form = $(el).find("form");
2343 2346

  
2344 2347
        // remove garbage rows that stay in DOM between requests
2345 2348
        $(".removable-field-row:hidden").remove();
2346 2349

  
2350
        // avoid buggy behaviour, close all overlays if something went wrong
2347 2351
        try {
2348
            $("#invform #removable-name-container-1").dynamicField();
2352
            // form is in content (form is not displayed if user has no invitations)
2353
            if ($("#invform #removable-name-container-1").length) {
2354
                $("#invform #removable-name-container-1").dynamicField();
2355
            }
2349 2356
        } catch (err) {
2350 2357
            close_all_overlays();
2351 2358
        }
2352 2359
        
2360
        // we copy/paste it on the title no need to show it twice
2353 2361
        $(".invitations-left").hide();
2362

  
2363
        // reset title
2354 2364
        $("#notification-box .header-box").html("");
2355 2365
        $("#notification-box .header-box").html(window.INVITATIONS_TITLE + " " + $($(".invitations-left")[0]).text());
2356 2366

  
2367
        // handle form submit
2357 2368
        form.submit(function(evn){
2358 2369
            evn.preventDefault();
2370

  
2371
            // do the post
2359 2372
            $.post(form.attr("action"), form.serialize(), function(data) {
2373
                // replace data
2360 2374
                $(cont).html(data); 
2375

  
2376
                // append all handlers again (new html data need to redo all changes)
2361 2377
                handle_invitations(cont);
2362 2378
            });
2379

  
2363 2380
            return false;
2364 2381
        });
2365 2382
    }
2366

  
2383
    
2384
    // first time clicked (show the msg box with /invitations content)
2367 2385
    msg_box({title:window.INVITATIONS_TITLE, content:'', ajax:INVITATIONS_URL, html:true, success: function(el){ 
2368 2386
        handle_invitations(el)}
2369 2387
    });

Also available in: Unified diff