errbit.js
3.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
// App JS
$(function() {
var currentTab = "summary";
function init() {
activateTabbedPanels();
activateSelectableRows();
toggleProblemsCheckboxes();
bindRequiredPasswordMarks();
$('#watcher_name').live("click", function() {
$(this).closest('form').find('.show').removeClass('show');
$('#app_watchers_attributes_0_user_id').addClass('show');
});
$('#watcher_email').live("click", function() {
$(this).closest('form').find('.show').removeClass('show');
$('#app_watchers_attributes_0_email').addClass('show');
});
$('a.copy_config').live("click", function() {
$('select.choose_other_app').show().focus();
});
$('select.choose_other_app').live("change", function() {
var loc = window.location;
window.location.href = loc.protocol + "//" + loc.host + loc.pathname +
"?copy_attributes_from=" + $(this).val();
});
$('input[type=submit][data-action]').click(function() {
$(this).closest('form').attr('action', $(this).attr('data-action'));
});
$('.notice-pagination').each(function() {
$('.notice-pagination a').pjax('#content', { timeout: 2000});
$('#content').bind('pjax:start', function() {
$('.notice-pagination-loader').css("visibility", "visible");
currentTab = $('.tab-bar ul li a.button.active').attr('rel');
});
$('#content').bind('pjax:end', function() {
activateTabbedPanels();
});
});
}
function activateTabbedPanels() {
$('.tab-bar a').each(function(){
var tab = $(this);
var panel = $('#'+tab.attr('rel'));
panel.addClass('panel');
panel.find('h3').hide();
});
$('.tab-bar a').click(function(){
activateTab($(this));
return(false);
});
activateTab($('.tab-bar ul li a.button[rel=' + currentTab + ']'));
}
function activateTab(tab) {
tab = $(tab);
var panel = $('#'+tab.attr('rel'));
tab.closest('.tab-bar').find('a.active').removeClass('active');
tab.addClass('active');
// If clicking into 'backtrace' tab, hide external backtrace
if (tab.attr('rel') == "backtrace") { hide_external_backtrace(); }
$('.panel').hide();
panel.show();
}
function toggleProblemsCheckboxes() {
var checkboxToggler = $('#toggle_problems_checkboxes');
checkboxToggler.live("click", function() {
$('input[name^="problems"]').each(function() {
this.checked = checkboxToggler.get(0).checked;
});
});
}
function activateSelectableRows() {
$('.selectable tr').click(function(event) {
if(!_.include(['A', 'INPUT', 'BUTTON', 'TEXTAREA'], event.target.nodeName)) {
var checkbox = $(this).find('input[name="problems[]"]');
checkbox.attr('checked', !checkbox.is(':checked'));
}
});
}
function bindRequiredPasswordMarks() {
$('#user_github_login').keyup(function(event) {
toggleRequiredPasswordMarks(this)
});
}
function toggleRequiredPasswordMarks(input) {
if($(input).val() == "") {
$('#user_password').parent().attr('class', 'required')
$('#user_password_confirmation').parent().attr('class', 'required')
} else {
$('#user_password').parent().attr('class', '')
$('#user_password_confirmation').parent().attr('class', '')
}
}
toggleRequiredPasswordMarks();
function hide_external_backtrace() {
$('tr.toggle_external_backtrace').hide();
$('td.backtrace_separator').show();
}
function show_external_backtrace() {
$('tr.toggle_external_backtrace').show();
$('td.backtrace_separator').hide();
}
// Show external backtrace lines when clicking separator
$('td.backtrace_separator span').live('click', show_external_backtrace);
// Hide external backtrace on page load
hide_external_backtrace();
$('.head a.show_tail').click(function(e) {
$(this).hide().closest('.head_and_tail').find('.tail').show();
e.preventDefault();
});
init();
});