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.
5 rootUi = new (function() {
7 this.onDomReady_ = function() {
8 $('#js_loading_banner').hide();
9 $('#tabs').tabs({activate: this.onTabChange_.bind(this)});
10 $('#tabs').css('visibility', 'visible');
12 // Initialize the status bar.
13 $('#status_messages').mouseenter(function() {
14 $('#status_bar').addClass('expanded');
15 $('#status_messages').scrollTop($('#status_messages').height());
17 $('#status_messages').mouseleave(function() {
18 $('#status_bar').removeClass('expanded');
20 $('#progress_bar').progressbar({value: 1});
23 this.showTab = function(tabId) {
24 var index = $('#tabs-' + tabId).index();
26 $('#tabs').tabs('option', 'active', index - 1);
29 this.onTabChange_ = function(_, ui) {
30 switch(ui.newPanel.attr('id').replace('tabs-', '')) {
32 return processes.redraw();
34 return profiler.redraw();
38 return nheap.redraw();
40 return settings.reload();
42 return storage.reload();
46 this.showDialog = function(content, title) {
47 var dialog = $('#message_dialog');
49 if (dialog.length == 0) {
50 dialog = $('<div id="message_dialog"/>');
51 $('body').append(dialog);
53 if (typeof(content) == 'string')
54 dialog.empty().text(content);
56 dialog.empty().append(content); // Assume is a jQuery DOM object.
58 dialog.dialog({modal: true, title: title, height:'auto', width:'auto'});
61 this.hideDialog = function() {
62 $('#message_dialog').dialog('close');
65 this.setProgress = function(value) {
66 $('#progress_bar').progressbar('option', 'value', value);
67 $('#progress_bar-label').text(value + '%' );
70 this.setStatusMessage = function(content) {
71 $('#status_messages').text(content);
74 $(document).ready(this.onDomReady_.bind(this));