Revision 91965c28 ui/templates/machines_single.html

b/ui/templates/machines_single.html
154 154
    </div>
155 155
    <div class="column3">
156 156
        <div class="controls">
157
            <div class="previous" style="display:none;">
157
            <div class="previous" style="display:block;">
158 158
                <div class="prev-arrow"></div>
159 159
                <div class="prev-label">
160 160
                    {% trans "previous" %}
161 161
                </div>
162 162
            </div>
163
            <div class="next" style="display:none;">
163
            <div class="next" style="display:block;">
164 164
                <div class="next-arrow"></div>
165 165
                <div class="next-label">
166 166
                    {% trans "next" %}
......
338 338
        existing_link = $('#machinesview-single div.column3 #link-' + server.id);
339 339
        var current_Id = current_serverId();
340 340

  
341
        //hide next button if there is only one vm
342
        if (data.servers.values.length == 1) {
343
            $("#machinesview-single.single .column3 .next").hide();
344
        }
345

  
346 341
        // if multiple machines exist in the DOM, delete all but one
347 342
        // defensive coding - that shouldn't happen normally
348 343
        while (existing.length > 1){
......
532 527
        $('.single').find('#' + $(this).attr('id').substring(5)).show();
533 528
        $('.single .column3').find('.column3-selected').removeClass('column3-selected');
534 529
        $(this).addClass('column3-selected');
535
        //show prev next links only if there are prev next servers
536
        if ($("#machinesview-single.single .column3 .column3-selected").attr("id") != $("#machinesview-single.single .column3 .server-name:eq(1)").attr("id")) {
537
            $(".single .column3 .previous").show();
538
        } else {
539
            $(".single .column3 .previous").hide();
540
        }
541
        if ($("#machinesview-single.single .column3 .column3-selected").attr("id") != $("#machinesview-single.single .column3 .server-name:last").attr("id")) {
542
            $(".single .column3 .next").show();
543
        } else {
544
            $(".single .column3 .next").hide();
545
        }
530
        update_prev_next()
546 531
    });
547 532

  
548 533
    if ($.cookie('server')) {
......
550 535
        $.cookie('server', null);
551 536
    }
552 537

  
553
    //if it is the last vm, hide the next button
538
    //if it is the last vm, disable the next button
554 539
    if ($("#machinesview-single.single .column3 .column3-selected").attr("id") == $("#machinesview-single.single .column3 .server-name:last").attr("id")) {
555
        $("#machinesview-single.single .column3 .next").hide()
556
    } else {
557
        $("#machinesview-single.single .column3 .next").show()
540
        $("#machinesview-single.single .column3 .next").addClass('disabled');
558 541
    }
559 542

  
560
    //if it is the first vm, hide the prev button
543
    //if it is the first vm, disable the prev button
561 544
    if ($("#machinesview-single.single .column3 .column3-selected").attr("id") == $("#machinesview-single.single .column3 .server-name:eq(1)").attr("id")) {
562
        $("#machinesview-single.single .column3 .previous").hide()
563
    } else {
564
        $("#machinesview-single.single .column3 .previous").show()
545
        $("#machinesview-single.single .column3 .previous").addClass('disabled');
565 546
    }
566 547
}
567 548

  
......
581 562
        $('#machinesview-single.single').find('#' + current_server).prev().show();
582 563
        $('#machinesview-single.single .column3').find('#link-' + current_server).removeClass('column3-selected');
583 564
        $('#machinesview-single.single .column3').find('#link-' + current_server).prev().addClass('column3-selected');
584
        if ($("#machinesview-single.single .column3 .column3-selected").attr("id") == $("#machinesview-single.single .column3 .server-name:eq(1)").attr("id")) {
585
            $(this).hide()
586
        }
587
        $("#machinesview-single.single .column3 .next").show()
565
        update_prev_next()
588 566
        return false;
589 567
    }
590 568
});
......
599 577
        $('#machinesview-single.single').find('#' + current_server).next().show();
600 578
        $('#machinesview-single.single .column3').find('#link-' + current_server).removeClass('column3-selected');
601 579
        $('#machinesview-single.single .column3').find('#link-' + current_server).next().addClass('column3-selected');
602
        //if it is the last vm, hide the next button
603
        if ($("#machinesview-single.single .column3 .column3-selected").attr("id") == $("#machinesview-single.single .column3 .server-name:last").attr("id")) {
604
            $(this).hide()
605
        }
606
        $("#machinesview-single.single .column3 .previous").show();
580
        update_prev_next()
607 581
        return false;
608 582
    }
609 583
});
610 584

  
611
//hide prev button on startup
612
$("#machinesview-single.single .column3 .previous").hide()
585

  
586
//enables-disables previous/next buttons accordingly
587
function update_prev_next() {
588
    if ($("#machinesview-single.single .column3 .column3-selected").attr("id") != $("#machinesview-single.single .column3 .server-name:eq(1)").attr("id")) {
589
        $(".single .column3 .previous").removeClass('disabled');
590
    } else {
591
        //disable class
592
        $(".single .column3 .previous").addClass('disabled');
593
    }
594
    if ($("#machinesview-single.single .column3 .column3-selected").attr("id") != $("#machinesview-single.single .column3 .server-name:last").attr("id")) {
595
        $(".single .column3 .next").removeClass('disabled');
596
    } else {
597
        //disable class
598
        $(".single .column3 .next").addClass('disabled');
599
    }
600
}
613 601

  
614 602
// basic functions executed on page load
615 603
if ( flavors.length == 0 && images.length == 0 ) {

Also available in: Unified diff