Blame view

dictionary/templates/lemma_preview.html 9.93 KB
Bartłomiej Nitoń authored
1
2
3
4
5
6
7
8
9
10
<script type="text/javascript">
 // <!-- 
  var prev_frames = new Array();
  var prev_nkjp_examples = new Array();
  var activePrevPanel = 'prev_frames_modif';
  var selectedPrevFrameIdNkjp = -1;
  var prev_selected_example_id = -1;
 
  frame_chars_str = '{{frame_char_list}}';
  frame_chars_str = convertHtml(frame_chars_str);
Bartłomiej Nitoń authored
11
  window.frame_char_order = serializedObjToObj(frame_chars_str);
Bartłomiej Nitoń authored
12
13

function selectPrevNkjpTr(id)
Bartłomiej Nitoń authored
14
{
Bartłomiej Nitoń authored
15
16
17
18
19
20
21
  if(window.prev_selected_example_id != -1)
  {
  	var recent_row = document.getElementById(window.prev_selected_example_id);
  	var recent_descendants = getDescendantsNodes(recent_row);
  	for(var i = 0; i<recent_descendants.length; i++)
  	  $(recent_descendants[i]).css("background-color", "");
  }
Bartłomiej Nitoń authored
22
Bartłomiej Nitoń authored
23
24
25
26
27
28
29
30
31
32
  if(window.prev_selected_example_id == id)
  {
  	  window.prev_selected_example_id = -1;
  }
  else
  {
  	window.prev_selected_example_id = id;
  	var row = document.getElementById(id);
  	var descendants = getDescendantsNodes(row);
  	for(var i = 0; i<descendants.length; i++)
Bartłomiej Nitoń authored
33
  	  $(descendants[i]).css("background-color", "LightSteelBlue");
Bartłomiej Nitoń authored
34
  	nkjpInstance = getNkjpExampleInstance(window.prev_nkjp_examples, id);
Bartłomiej Nitoń authored
35
Bartłomiej Nitoń authored
36
37
38
39
40
41
 // wyswietlanie komentarza jesli istnieje
  	if(nkjpInstance.comment)
  	{
  	   var nkjp_table_container = document.getElementById("show_prev_nkjp_table");
  	   var last_shown_comm_elem = document.getElementById('prev_example_comment');
  	   $(last_shown_comm_elem).remove();
Bartłomiej Nitoń authored
42
Bartłomiej Nitoń authored
43
44
45
46
47
48
49
50
51
52
53
  	   var outer_div = document.createElement('div');
  	   outer_div.setAttribute('id', 'prev_example_comment');
  	   var strong = document.createElement('strong');
  	   strong.appendChild(document.createTextNode("Komentarz do przykładu:"));
  	   outer_div.appendChild(strong);
  	   div = document.createElement('div');
  	   pre = document.createElement('pre');
  	   pre.appendChild(document.createTextNode(nkjpInstance.comment));
  	   div.appendChild(pre);
  	   outer_div.appendChild(div);
  	   nkjp_table_container.appendChild(outer_div);
Bartłomiej Nitoń authored
54
55
  	}
Bartłomiej Nitoń authored
56
57
58
59
60
    //selectTd(nkjpInstance.frame_id);
    var parent = document.getElementById("prev-lemma-tables");
    var matching_elements = getMatchingElements(parent, nkjpInstance.frame_id);
	for(var i=0; i<matching_elements.length; i++)
      $(matching_elements[i]).css("background-color", "LightSteelBlue");
Bartłomiej Nitoń authored
61
Bartłomiej Nitoń authored
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
    for(var i=0; i<nkjpInstance.arguments_ids.length; i++)
    {
      unselectPrevTd(nkjpInstance.arguments_ids[i]);
    }
  }
}
 
function selectPrevTd(id)
{     
  	var parent = document.getElementById("prev-lemma-tables");
  	var recent_sel_elements = new Array();
  	
  	if(window.activePrevPanel == 'prev_frames_modif')
  	{
  	  if(prev_selected_id != -1)
  	  {
  	    recent_sel_elements = getMatchingElements(parent, prev_selected_id);
  	    for(var i=0; i<recent_sel_elements.length; i++)
		  $(recent_sel_elements[i]).css("background-color", "");
  	  }
  	
  	  if(prev_selected_id == id)
  	    prev_selected_id = -1;
  	  else
  	  {
  	    prev_selected_id = id;
  	    var matching_elements = getMatchingElements(parent, id);
	    for(var i=0; i<matching_elements.length; i++)
          $(matching_elements[i]).css("background-color", "LightSteelBlue");
  	  }
  	}
  	else if(window.activePrevPanel == 'show_prev_nkjp_example')
  	{
  	  elementInstance = getElementInstance(id, window.prev_frames);
  	  if(elementInstance['type'] == 'frame')
  	  {
  	    prev_selected_example_id = -1;
  	    if(id != window.selectedPrevFrameIdNkjp)
  	      unselectPrevTd(window.selectedPrevFrameIdNkjp);
  	      
  	    window.selectedPrevFrameIdNkjp = id;
  	    var parent = document.getElementById("prev-lemma-tables");
  	    var matching_elements = getMatchingElements(parent, id);
	    for(var i=0; i<matching_elements.length; i++)
          $(matching_elements[i]).css("background-color", "LightSteelBlue");
          
        var table_container = document.getElementById("show_prev_nkjp_table");
Bartłomiej Nitoń authored
109
110
        draw_nkjp_table(table_container, id, prev_nkjp_examples, 'PrevNkjpTableRow', 'nkjp_');
        $("tr.PrevNkjpTableRow").click(function(){
Bartłomiej Nitoń authored
111
112
113
114
115
116
117
118
119
120
121
122
123
124
          selectPrevNkjpTr(this.id)});
  	  }
  	}  	
}

function unselectPrevTd(id)
{ 
  	var parent = document.getElementById("prev-lemma-tables");
  	var recent_sel_elements = getMatchingElements(parent, id);
  	for(var i=0; i<recent_sel_elements.length; i++)
	  $(recent_sel_elements[i]).css("background-color", "");
}

  function draw_filtered_prev_frames()
Bartłomiej Nitoń authored
125
126
  { 
    window.prev_filter_schema_type_val = $('#prev_frame_filter #schema_type_filter').val();
Bartłomiej Nitoń authored
127
128
129
130
    window.prev_filter_aspect_val = $('#prev_frame_filter #aspect_filter').val();
    window.prev_filter_reflex_val = $('#prev_frame_filter #reflex_filter').val();
    window.prev_filter_neg_val = $('#prev_frame_filter #neg_filter').val();
    window.prev_filter_pred_val = $('#prev_frame_filter #pred_filter').val();
Bartłomiej Nitoń authored
131
    window.prev_filter_opinion_val = $('#prev_frame_filter #opinion_filter').val();
Bartłomiej Nitoń authored
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
165
166
    window.prev_filter_position_val = $('#prev_frame_filter #position_filter').val();
    window.prev_filter_argument_val = $('#prev_frame_filter #argument_filter').val();
    
    draw_filtered_frames(window.prev_frames, 'prev-lemma-tables', 'prev-lemma-table', 'prev_frame_filter', window.prev_nkjp_examples, 'InactiveFrameTable', window.prev_lemma_entry);
  }

  $("button#prev_copy").click(function(){copyElement()}); 
  $("button#prev_relate_entries").click(function(){relateEntries()});
  $("button#prev_disrelate_entries").click(function(){disrelateEntries()});
  
  // -->
</script>
<div id='prevFramesSplit'>
  <div id="prev-lemma-tables">
  </div>  
  <div id="prev_tabs" class="prev_tabs">
    <ul>
    <!--li id='prev_lemma_info' style="float:left;">{{selected_lemma.entry}} ({{selected_lemma.vocabulary.name}})</li-->
      <li><a href="#prev_frames_modif">Modyfikacja schematów</a></li>
      <li><a href="#show_prev_nkjp_example">Przegląd przykładów</a></li>
      <li><a href="#similar_lemmas">Czasowniki podobne</a></li>
      <span id="cancel_prev_frame_filter" style="float:right;">x</span>
      <span style="float:right;"> 
        <ul id="filter_frames_menu">
          <li id="prev_filter_frames_options"><a href="#">Filtrowanie schematów</a>
            <ul id="options">
              <li id="prev_frame_filter"><a href="#"></a></li>
            </ul>
          </li>
        </ul>
      </span>
    </ul>


      <div id="prev_frames_modif">
Bartłomiej Nitoń authored
167
168
169
170
171
172
173
        {% if perms.dictionary.add_syntactic_frames or perms.dictionary.add_phraseologic_frames or perms.dictionary.add_semantic_frames%}
          {% if perms.dictionary.add_syntactic_frames or perms.dictionary.add_phraseologic_frames %}
            <div>
          	  <button type="button" id="prev_copy" style="width:120px">Kopiuj</button>
            </div>
          {% endif %}
          {% if perms.dictionary.add_syntactic_frames or perms.dictionary.add_semantic_frames %}
Bartłomiej Nitoń authored
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
            <div>
              <button type="button" id="prev_relate_entries" style="width:120px">Powiąż hasła</button>
              <button type="button" id="prev_disrelate_entries" style="width:140px; visibility:hidden;">Anuluj powiązanie</button>
            </div>
          {% endif %}
        {% else %}
          Brak możliwych działań.
        {% endif %}
      </div>

    <div id="show_prev_nkjp_example">
      <div id="show_prev_nkjp_table">
        Wybierz schemat, aby zobaczyć dodane do niego przykłady.
      </div>
    </div>
    <div id="similar_lemmas">
      <strong>Powiązane hasła:</strong>
      <button id="related-lemmas-show">
      	Pokaż
      </button></br>
      <strong>Podobieństwo znaczeniowe:</strong>
      <button id="similar-lemmas-show-synonyms">
      	Pokaż podobne
      </button></br>
      <strong>Nowe schematy:</strong>
      <form class="similar-lemmas-new-form" method="post"> {% csrf_token %}
        {{ similarLemmasNewForm.as_p }}
        <p class="lexeme-save">
          <button type="submit" id="similar-lemmas-new-form-submit">
            Pokaż podobne
          </button>
          <button type="reset" id="similar-lemmas-new-form-cancel">
            Wyczyść
          </button>
        </p>
      </form>
    </div>
  </div>
</div>


<script type="text/javascript">
$(document).ready(function() {
    window.prev_lemma_entry = '{{selected_lemma.entry}}';
    window.activePrevPanel = 'prev_frames_modif';
    $(".prev_tabs").tabs().bind('tabsselect', function(event, ui) {
         window.activePrevPanel = ui.panel.id;
       // czyszczenie zaznaczen elementow w tablicach (trzeba to jeszcze fizycznie zrobic)
         unselectPrevTd(window.prev_selected_id);
         window.prev_selected_id = -1;
         unselectPrevTd(window.selectedPrevFrameIdNkjp);
         //$('#show_prev_nkjp_table').empty();
         window.selectedPrevFrameIdNkjp = -1;
         prev_selected_example_id = -1;
    });
    
    draw_frames_filter('prev_frame_filter');
    $('#prev_filter_frames_options #options').hide();
    $('#prev_filter_frames_options').click(function(){
        $('#prev_filter_frames_options #options').slideToggle('fast');
    });
Bartłomiej Nitoń authored
235
    $('#prev_frame_filter #schema_type_filter').change(draw_filtered_prev_frames);
Bartłomiej Nitoń authored
236
237
238
239
    $('#prev_frame_filter #aspect_filter').change(draw_filtered_prev_frames);
    $('#prev_frame_filter #reflex_filter').change(draw_filtered_prev_frames);
    $('#prev_frame_filter #neg_filter').change(draw_filtered_prev_frames);
    $('#prev_frame_filter #pred_filter').change(draw_filtered_prev_frames);
Bartłomiej Nitoń authored
240
    $('#prev_frame_filter #opinion_filter').change(draw_filtered_prev_frames);
Bartłomiej Nitoń authored
241
242
243
244
245
    $('#prev_frame_filter #argument_filter').change(draw_filtered_prev_frames);
    $('#prev_frame_filter #position_filter').change(draw_filtered_prev_frames);
    $('#prev_filter_frames_options #options').click(function(event) {
        event.stopPropagation();
    }); 
Bartłomiej Nitoń authored
246
    $('#cancel_prev_frame_filter').click(cancel_prev_schemata_filtering);
Bartłomiej Nitoń authored
247
248
});
</script>