rootUi.js revision a1401311d1ab56c4ed0a474bd38c108f75cb0cd9
1// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5rootUi = new (function() {
6
7this.onDomReady_ = function() {
8  $('#js_loading_banner').hide();
9  $('#tabs').tabs({activate: this.onTabChange_.bind(this)});
10  $('#tabs').css('visibility', 'visible');
11
12  // Initialize the status bar.
13  $('#status_messages').mouseenter(function() {
14    $('#status_bar').addClass('expanded');
15    $('#status_messages').scrollTop($('#status_messages').height());
16  });
17  $('#status_messages').mouseleave(function() {
18    $('#status_bar').removeClass('expanded');
19  });
20  $('#progress_bar').progressbar({value: 1});
21};
22
23this.showTab = function(tabId) {
24  var index = $('#tabs-' + tabId).index();
25  if (index > 0)
26    $('#tabs').tabs('option', 'active', index - 1);
27};
28
29this.onTabChange_ = function(_, ui) {
30  switch(ui.newPanel.attr('id').replace('tabs-', '')) {
31    case 'ps':
32      return processes.redraw();
33    case 'prof':
34      return profiler.redraw();
35    case 'mm':
36      return mmap.redraw();
37    case 'settings':
38      return settings.reload();
39    case 'storage':
40      return storage.reload();
41  }
42};
43
44this.showDialog = function(content, title) {
45  var dialog = $('#message_dialog');
46  title = title || '';
47  if (dialog.length == 0) {
48    dialog = $('<div id="message_dialog"/>');
49    $('body').append(dialog);
50  }
51  if (typeof(content) == 'string')
52    dialog.empty().text(content);
53  else
54    dialog.empty().append(content);  // Assume is a jQuery DOM object.
55
56  dialog.dialog({modal: true, title: title, height:'auto', width:'auto'});
57};
58
59this.hideDialog = function() {
60  $('#message_dialog').dialog('close');
61};
62
63this.setProgress = function(value) {
64  $('#progress_bar').progressbar('option', 'value', value);
65  $('#progress_bar-label').text(value + '%' );
66};
67
68this.setStatusMessage = function(content) {
69  $('#status_messages').text(content);
70};
71
72$(document).ready(this.onDomReady_.bind(this));
73
74})();