Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / tools / memory_inspector / memory_inspector / frontends / www_content / js / rootUi.js
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
5 rootUi = new (function() {
6
7 this.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
23 this.showTab = function(tabId) {
24   var index = $('#tabs-' + tabId).index();
25   if (index > 0)
26     $('#tabs').tabs('option', 'active', index - 1);
27 };
28
29 this.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 'nheap':
38       return nheap.redraw();
39     case 'settings':
40       return settings.reload();
41     case 'storage':
42       return storage.reload();
43   }
44 };
45
46 this.showDialog = function(content, title) {
47   var dialog = $('#message_dialog');
48   title = title || '';
49   if (dialog.length == 0) {
50     dialog = $('<div id="message_dialog"/>');
51     $('body').append(dialog);
52   }
53   if (typeof(content) == 'string')
54     dialog.empty().text(content);
55   else
56     dialog.empty().append(content);  // Assume is a jQuery DOM object.
57
58   dialog.dialog({modal: true, title: title, height:'auto', width:'auto'});
59 };
60
61 this.hideDialog = function() {
62   $('#message_dialog').dialog('close');
63 };
64
65 this.setProgress = function(value) {
66   $('#progress_bar').progressbar('option', 'value', value);
67   $('#progress_bar-label').text(value + '%' );
68 };
69
70 this.setStatusMessage = function(content) {
71   $('#status_messages').text(content);
72 };
73
74 $(document).ready(this.onDomReady_.bind(this));
75
76 })();