control.html
6.42 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
{% load staticfiles %}
{% load hash %}
<script>
var roles_display = []
{% for role_id in role_children %}
roles_display[{{ role_id }}] = []
{% for role in role_children|hash:role_id %}
roles_display[{{ role_id }}].push({ id: {{ role.id }}, role: "{{ role.role }}" })
{% endfor %}
{% endfor %}
function display_subroles(role_id, checked) {
if (checked) {
text = ''
for (i = 0; i < roles_display[role_id].length; i++) {
input_text = '<input type="checkbox" name="roles" value="' +
roles_display[role_id][i]["id"] +
'" onclick="display_subroles(' +
roles_display[role_id][i]["id"] +
', 1, this.checked)"><label>' +
roles_display[role_id][i]["role"] +
'</label><div id="subroles_' +
roles_display[role_id][i]["id"] +
'"></div>'
text += input_text
}
$("#subroles_" + role_id).html(text)
$("#subroles_" + role_id).css('position', 'absolute')
$("#subroles_" + role_id).css('left', 50)
} else {
$("#subroles_" + role_id).html('')
}
}
function dodaj() {
if (highlighted_id) {
if (highlighted_id.split('_').length == 3) {/* frame selected, new complement */
var dodaj_dopełnienie = {
state0: {
title: 'Nowy argument',
html:'Wybierz role dla nowego argumentu:<br>' +
'<table border="1" style="font-size: 11px">' +
{% for row in roles_display %}
'<tr>' +
{% for rowspan, colspan, roles in row %}
'<td rowspan="{{ rowspan }}" colspan="{{ colspan }}">' +
{% for role in roles %}
'<div><input type="checkbox" name="roles" value="{{ role.id }}"><label>{{ role.role }}</label></div>' +
{% endfor %}
'</td>' +
{% endfor %}
'</tr>' +
{% endfor %}
'</table>',
buttons: { Anuluj: 0, Zatwierdź: 1 },
focus: 1,
submit:function(e,v,m,f){
if (v > 0) {
if (f.roles.length > 0) {
$("#semantic_right").load(ajax_create_complement, "lemma_id=" + {{ lemma.id }} + "&frame=" + highlighted_id.split('_')[1] + "&roles=" + f.roles);
}
}
e.preventDefault();
$.prompt.close();
}
},
};
$.prompt(dodaj_dopełnienie);
} else { /* complement selected, new selective_preference */
var dodaj_preferencje = {
state0: {
title: 'Nowe preferencje selekcyjne',
html:'Chwilowo niedostępne',
buttons: { Anuluj: 0 },
focus: 1,
submit:function(e,v,m,f){
e.preventDefault();
$.prompt.close();
}
},
};
$.prompt(dodaj_preferencje);
}
} else {
var dodaj_rame = {
state0: {
title: 'Nowa rama',
html:'Wybierz jednostki leksykalne, dla których chcesz stworzyć ramę:<br>'+
{% for lexical_unit in lexical_units %}
'<input type="checkbox" name="lexical_units" value="{{ lexical_unit.id }}"><label>{{ lexical_unit.base }}-{{ lexical_unit.sense }}</label><br>' +
{% endfor %}
'</select>',
buttons: { Anuluj: 0, Zatwierdź: 1 },
focus: 1,
submit:function(e,v,m,f){
if (v > 0) {
if (f.lexical_units.length > 0) {
$("#semantic_right").load(ajax_create_frame, "lexical_units=" + f.lexical_units + "");
}
}
e.preventDefault();
$.prompt.close();
}
},
};
$.prompt(dodaj_rame);
}
}
function zapisz_powiazania() {
}
$(document).ready(function(){
control="modify"
$("#select_modify_frames").click(function(e) {
$("#connect").addClass("ui-tabs-hide")
$("#select_connect").parent().removeClass("ui-state-active")
$("#select_connect").parent().removeClass("ui-state-focus")
$("#modify_frames").removeClass("ui-tabs-hide")
$("#select_modify_frames").parent().addClass("ui-state-active")
$("#select_modify_frames").parent().addClass("ui-state-focus")
control="modify"
frameClick("","")
});
$("#select_connect").click(function(event){
$("#modify_frames").addClass("ui-tabs-hide")
$("#select_modify_frames").parent().removeClass("ui-state-active")
$("#select_modify_frames").parent().removeClass("ui-state-focus")
$("#connect").removeClass("ui-tabs-hide")
$("#select_connect").parent().addClass("ui-state-active")
$("#select_connect").parent().addClass("ui-state-focus")
control="connect"
frameClick("","")
});
})
</script>
<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active">
<a id="select_modify_frames" href="#">Modyfikacja ramek</a>
</li>
<li class="ui-state-default ui-corner-top">
<a id="select_connect" href="#">Edycja połączeń</a>
</li>
</ul>
<div id="modify_frames" class="ui-tabs-panel ui-widget-content ui-corner-bottom">
<button type="button" onclick="dodaj()" id="create">Nowa</button>
</div>
<div id="connect" class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide">
<button type="button" onclick="zapisz_powiazania()" id="create">Zapisz</button>
</div>