Revision e5b2315d

View differences:

src/sunstone/public/app/sunstone.js
36 36
    for (tabName in SunstoneCfg["tabs"]) {
37 37
      _insertTab(tabName);
38 38
      _insertButtonsInTab(tabName);
39
      _initializeDataTable(tabName);
39
      _setupDataTable(tabName);
40 40

  
41 41
      // TODO Add openenbula actions
42 42
      /*if (config['view']['autorefresh']) {
......
53 53
    _setupTabs();
54 54
  }
55 55

  
56
  var _initializeDataTable = function(tabName) {
56
  var _setupDataTable = function(tabName) {
57 57
    if (SunstoneCfg['tabs'][tabName].dataTable) {
58 58
      SunstoneCfg['tabs'][tabName].dataTable.initialize();
59 59
    }
......
362 362
        return false;
363 363
      } else {
364 364
        var tabName = $(this).attr('id').substring(3);
365
        showTab(tabName);
365
        _showTab(tabName);
366 366
        return false;
367 367
      }
368 368
    });
......
376 376
        subtabs.fadeToggle('fast');
377 377
        return false;
378 378
      } else {
379
        showTab(tabName);
379
        _showTab(tabName);
380 380
        return false;
381 381
      }
382 382
    });
......
384 384
    _setupButtons();
385 385
  };
386 386

  
387
  var showTab = function(tabName) {
387
  var _showRighList = function(tabName){
388
    var tab = $('#' + tabName);
389
    $(".tab").hide();
390
    tab.show();
391

  
392
    $(".right-info", tab).hide();
393
    $(".right-form", tab).hide();
394
    $(".right-list", tab).show();
395
    $(".only-right-info", tab).hide();
396
    $(".only-right-form", tab).hide();
397
    $(".only-right-list", tab).show();
398
  };
399

  
400
  var _showRighInfo = function(tabName){
401
    var tab = $('#' + tabName);
402
    $(".tab").hide();
403
    tab.show();
404

  
405
    $(".right-list", tab).hide();
406
    $(".right-form", tab).hide();
407
    $(".right-info", tab).show();
408
    $(".only-right-list", tab).hide();
409
    $(".only-right-form", tab).hide();
410
    $(".only-right-info", tab).show();
411
  }
412

  
413
  var _showTab = function(tabName) {
388 414
    if (!SunstoneCfg['tabs'][tabName]) {
389 415
      return false;
390 416
    }
......
398 424

  
399 425
    //clean selected menu
400 426
    $("#navigation li").removeClass("navigation-active-li");
401

  
402
    //select tab in left menu
403
    var li = $("#navigation li#li_" + tabName)
404
    li.addClass("navigation-active-li");
427
    $("#navigation li#li_" + tabName).addClass("navigation-active-li");
405 428

  
406 429
    var tab = $('#' + tabName);
407 430
    //show tab
408
    $(".tab").hide();
409
    tab.show();
410
    $(".right-info", tab).hide();
411
    $(".right-form", tab).hide();
412
    $(".right-list", tab).show();
413
    $(".only-right-info", tab).hide();
414
    $(".only-right-form", tab).hide();
415
    $(".only-right-list", tab).show();
431
    _showRighList(tabName);
416 432

  
417 433
    // TODO Add recountCheckboxes
418 434
    //recountCheckboxes($(".dataTable", tab).first());
419 435

  
420
    // TODO Add opennebula.js
421
    /*var res = SunstoneCfg['tabs'][activeTab]['resource']
436
    var res = SunstoneCfg['tabs'][tabName]['resource']
422 437
    if (res) {
423 438
      Sunstone.runAction(res + ".list");
424
    } else {
425
      var action = activeTab + ".refresh";
426

  
427
      if (SunstoneCfg["actions"][action]) {
428
        Sunstone.runAction(action);
429
      }
430
    }*/
439
    }
431 440
  }
432 441

  
433 442
  var _showElement = function(tabName, infoAction, elementId) {
434
    showTab(tabName);
443
    _showTab(tabName);
435 444

  
436 445
    var context = $('#' + tabName);
437 446

  
438 447
    $(".resource-id", context).html(elementId);
439 448
    $(".resource-info-header", context).text("");
440 449

  
441
    _popDialogLoading(context);
450
    var loading = '<div style="margin-top: 20px; text-align: center; width: 100%"><img src="images/pbar.gif" alt="loading..." /></div>';
451
    $(".right-info", context).html(loading);
452
    _showRighInfo(tabName);
442 453

  
443 454
    Sunstone.runAction(infoAction, elementId);
444 455
    //enable action buttons
445 456
    $('.top_button, .list_button', context).attr('disabled', false);
446 457
  }
447 458

  
448
  var _popDialog = function(content, context) {
449
    $(".right-info", context).html(content);
450
    context.foundation();
451
  }
452

  
453
  var _popDialogLoading = function(context) {
454
    $(".right-list", context).hide();
455
    $(".right-form", context).hide();
456
    $(".right-info", context).show();
457
    $(".only-right-list", context).hide();
458
    $(".only-right-form", context).hide();
459
    $(".only-right-info", context).show();
460
    var loading = '<div style="margin-top: 20px; text-align: center; width: 100%"><img src="images/pbar.gif" alt="loading..." /></div>';
461
    _popDialog(loading, context);
462
  }
463

  
464 459
  var _insertPanels = function(tabName, info) {
465 460
    var containerId = tabName + '-panels';
466 461
    var activaTab = $("dd.active a", $("#" + containerId));
......
499 494
    });
500 495

  
501 496
    var TemplatePanels = require('hbs!./sunstone/panels');
502
    _popDialog(TemplatePanels(templateAttrs), $("#" + tabName));
497
    $(".right-info", $("#" + tabName)).html(TemplatePanels(templateAttrs));
503 498
  }
504 499

  
505 500
  //Runs a predefined action. Wraps the calls to opennebula.js and
......
603 598
  }
604 599

  
605 600
  var Sunstone = {
606
    "showAction" : function() {
607
      return SunstoneCfg["actions"];
608
    },
609

  
610
    //Adds several actions encapsulated in an js object.
601
     //Adds several actions encapsulated in an js object.
611 602
    "addActions" : _addActions,
612 603

  
613 604
    "addMainTab" : _addMainTab,
......
617 608
      SunstoneCfg["form_panels"][formName] = formObj;
618 609
    },
619 610

  
620
    // TODO Not necessary, updateInfoPanelTab overwrites it
621
    //Adds a new info panel
622
    "addInfoPanel" : function(panelName, panelObj) {
623
      SunstoneCfg["info_panels"][panelName] = panelObj;
624
    },
625

  
626 611
    //Makes an info panel content pop up in the screen.
627 612
    "showElement" : _showElement,
628 613
    "insertPanels" : _insertPanels,
629 614

  
630
    // Replaces a tab from an info panel. Refreshes the DOM if wanted.
631
    "updateInfoPanelTab" : function(panelName, panelTabId, panelTabObj, refresh) {
632
      SunstoneCfg["info_panels"][panelName][panelTabId] = panelTabObj;
633
      if (refresh) {
634
        var tabContent = panelTabObj.content;
635
        $('div#' + panelName + ' div#' + panelTabId, info_panel_context).html(tabContent);
636
      }
637
    },
638 615

  
639 616
    "popUpFormPanel" : function(formName, selectedTab, action, reset, initalizeFunc) {
640 617
      var context = $("#" + selectedTab);
......
732 709

  
733 710
    'insertTabs': _insertTabs,
734 711
    // TODO check if it used externally
735
    //'showTab': showTab
712
    //'showTab': _showTab
736 713
  };
737 714

  
738 715
  return Sunstone;

Also available in: Unified diff