lemma_preview.html 10.6 KB
<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);
  window.frame_char_order = serializedObjToObj(frame_chars_str)
 
  serialized_text = '{{serialized_frames}}';
  serialized_text = convertHtml(serialized_text);
  serialized_frames = serialized_text; 
  window.prev_frames = serializedObjToObj(serialized_frames);
  
  nkjp_examples_str = '{{nkjp_examples}}';
  nkjp_examples_str = convertHtml(nkjp_examples_str);
  window.prev_nkjp_examples = serializedNkjpToObj(nkjp_examples_str);


function selectPrevNkjpTr(id)
{  	  
  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", "");
  }
  	
  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++)
  	  $(descendants[i]).css("background-color", "LightSteelBlue");  	  
  	nkjpInstance = getNkjpExampleInstance(window.prev_nkjp_examples, id);
 
 // 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();
  	   
  	   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);
  	}	 
  	
    //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");
      
    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");
        draw_nkjp_table(table_container, id, prev_nkjp_examples, 'NkjpTableRow', 'nkjp_');
        $("tr.NkjpTableRow").click(function(){
          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()
  {
    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();
    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">
        {% 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>
          {% if perms.dictionary.add_syntactic_frames %}
            <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');
    });
    $('#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);
    $('#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();
    }); 
    $('#cancel_prev_frame_filter').click(function(event) {
	    window.prev_filter_position_val = '.*';
	    window.prev_filter_argument_val = '.*';  
	    window.prev_filter_aspect_val = '*';
	    window.prev_filter_reflex_val = '*';
	    window.prev_filter_neg_val = '*';
	    window.prev_filter_pred_val = '*';
	    $('#prev_frame_filter #argument_filter').val(window.prev_filter_argument_val);
	    $('#prev_frame_filter #position_filter').val(window.prev_filter_position_val);
	    $('#prev_frame_filter #aspect_filter').val(window.prev_filter_aspect_val);
	    $('#prev_frame_filter #reflex_filter').val(window.prev_filter_reflex_val);
	    $('#prev_frame_filter #neg_filter').val(window.prev_filter_neg_val);
	    $('#prev_frame_filter #pred_filter').val(window.prev_filter_pred_val);
	    $('#prev_frame_filter #argument_filter').trigger('change');
    }); 
    draw_filtered_prev_frames();
});
</script>