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
|
define(['jquery', 'jquery-ui', 'view/helpers', 'view/internal'],
function($, _unused_jquery_ui, view_helpers, internal) {
var d = null,
submit_callback = null,
delete_callback = null;
function _get_form_data() {
return {
name: $('.info #editformname').val(),
type: $('.info #edittype').val(),
url: $('.info #editurl').val(),
status: $('.info #editstatus').val(),
startdate: $("#editstartdate").val(),
enddate: $("#editenddate").val(),
};
}
//internal.edit_tab.get('node', "#editbox").submit(function(e) {
// if (submit_callback) {
// return submit_callback(e, _get_form_data());
// }
// console.log('bug: edit tab submit called with no callback set');
// e.preventDefault();
//})
//internal.edit_tab.get('node', "#deletenode").click(function(e) {
// if (delete_callback) {
// return delete_callback(e, _get_form_data());
// }
// console.log('bug: edit tab delete called with no callback set');
// e.preventDefault();
//});
function show(d) {
var info = $('.info'),
f = false,
t = true,
visible = {
"third-internship-proposal": [t, t, t, f, f],
"chainlink": [f, f, f, f, f],
"skill": [f, f, f, f, t],
"interest": [f, f, f, f, t],
"_defaults": [f, f, f, f, t],
},
fields = ["#status", "#startdate", "#enddate", "#desc", "#url"],
flags = visible.hasOwnProperty(d.type) ? visible[d.type] : visible._defaults,
i;
internal.edit_tab.show('node');
for (i = 0 ; i < flags.length; ++i) {
var elem = info.find(fields[i]);
elem[flags[i] ? 'show' : 'hide']();
}
$('.info').attr('class', 'info');
$('.info').addClass('type-' + d.type); // Add a class to distinguish types for css
$('.info').find('#editformname').val(d.name);
$("#editenddate").datepicker({
inline: true,
showOtherMonths: true,
dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
});
$("#editstartdate").datepicker({
inline: true,
showOtherMonths: true,
dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
});
$('#editdescription').val(d.type);
$('#edittype').val(d.type);
$('#editurl').val(d.url);
$('#editstatus').val(d.status);
if (d.type === "third-internship-proposal") {
$('#editstartdate').val(d.start);
$('#editenddate').val(d.end);
}
}
function hide()
{
internal.edit_tab.hide();
}
function on_save(f) {
$('#edit-node-dialog__save').click(function(e) {
return f(e, _get_form_data());
});
}
function on_delete(f) {
$('#edit-node-dialog__delete').click(function(e) {
return f(e, _get_form_data());
});
}
function on_keyup(f) {
$('.info').keyup(function(e) {
return f(e, _get_form_data());
});
}
return {
show: show,
hide: hide,
on_save: on_save,
on_delete: on_delete,
on_keyup: on_keyup,
};
});
|