entry-layout.js 7.28 KB
var myLayout;
var change = false;
var notesNotSaved = false;
var lemmaExNotSaved = false;
var frames_operations = [];

$(window).bind('beforeunload', function() {
	  warnings = ""
      if(change)
    	  warnings = warnings + "  - Nie zapisano zmian w schematach składniowych.\n";
	  if(typeof semanticsChanged != "undefined" && semanticsChanged())
    	  warnings = warnings + "  - Nie zapisano zmian w ramach semantycznych.\n";
      if(notesNotSaved)
    	  warnings = warnings + "  - Nie zapisano notatki.\n";
      if(lemmaExNotSaved)
    	  warnings = warnings + "  - Nie zapisano przykładu niedowiązangeo.\n";
      if(warnings)
    	  return "Uwaga:\n" + warnings
    });

$(function() {
  $('#content').height($(window).height() - 20);
  $(window).resize(function() {
    $('#content').height($(window).height() - 20);
    resize_splitters();
  });
  if ($.fn.splitter) {
    $('#content').bind('resize', function(e) {
      resize_splitters();
      e.stopPropagation();
    });
    $('#content').bind('resize', function(e) {
      e.stopPropagation();
    });
  }
});

function ShowProgressAnimation()
{
  $("#wait-dialog").dialog('open');
}

function HideProgressAnimation()
{
  $("#wait-dialog").dialog('close');
}

function resize_splitters() {
  $('#semantics-hsplit').trigger('resize');
}

function createWaitDialog()
{
    $("#wait-dialog").dialog({ autoOpen: false,
                               modal   : 'true',
                               closeOnEscape: 'false',
                               closeText: '',
                               bgiframe: 'true',
                               resizable: 'false',
                               open: function (event, ui) {
                                   $('#wait-dialog').css('overflow', 'hidden');
                               }});
    $(".ui-dialog-titlebar").hide();
}

function refresh_column_headers() {}

function load_content(id) {
  $('#add-table-elem-dialog').dialog('close');
  if(lemma_id != id)
    $('#ready-note-dialog').dialog('close');
  initiateFrameFilters();

	ShowProgressAnimation();
    // czyszczenie wartosci
	window.elem_in_bucket = '';
    window.selected_notes_row_id = -1;
    window.selected_id = -1;
    window.prev_selected_id = -1;
    window.edited_id = -1;
    window.manipulated_id = -1;
    window.new_elem_id = -2;
    window.copy_elem_id = -1;
    window.activeNewFramePanel = 'frames_modif';
    window.selectedArgumentsIdNkjp = new Array();
    window.selectedFrameIdNkjp = -1;
    window.nkjp_examples = new Array();
    window.curr_example_id = -1;
    window.selected_example_id = -1;
    window.lemma_nkjp_examples = new Array();
    window.curr_lemma_example_id = -1;
    window.selected_lemma_example_id = -1;
    window.addedFrame = '';

    $('#new_frames').empty();
    window.change = false;
    window.notesNotSaved = false;
    window.lemmaExNotSaved = false;

    $('#new_frames').load(ajax_new_frames, 'id='+id, function(data){
        window.lemma_id = id;

        loadSchemataAndExamples();

        createSplitter('framesSplit','new-frame-tables', 'tabs');

  		if(document.getElementById("lemma_example_show"))
  		{
  		  draw_nkjp_table(document.getElementById("lemma_example_show"), '', window.nkjp_lemma_examples, 'NkjpLemmaTableRow', 'nkjpLemma_')
          $("tr.NkjpLemmaTableRow").click(function(){
            selectLemmaNkjpTr(this.id)});
        }
  		addPinnedExamplesDialog();
  	    $('#lemma_desc').load(ajax_get_lemma_desc, 'id='+id);
  	    areNewPreviewEntriesRelated();
  		refresh_example_propositions();
      });
      $('#semantics').load(ajax_semantics, 'id='+id);
}

function createSplitter(split_id, top_id, bottom_id) {
  $('#'+split_id).height($('#content').height() - 50);
  if ($.fn.splitter) {
	$(window).resize(function() {
		$('#'+split_id).height($('#content').height() - 50);
	});
    $('#'+top_id).bind('resize', function(e) {
      e.stopPropagation();
    });
    $('#'+bottom_id).bind('resize', function(e) {
      e.stopPropagation();
    });
    $('#'+split_id).splitter({
      type: "h",
      minTop: 200,
      minBottom: 50,
      sizeBottom: 170,
      resizeToWidth: true
    });
  }
}


var hSplitterId = 'semantics-hsplit';
var topSplitId = 'semantics-hsplit-top';
var bottomSplitId = 'semantics-hsplit-bottom';
var topVSplitterId = 'semantics-vsplit-top';
var bottomVSplitterId = 'semantics-vsplit-bottom';
var topLeftSplitId = 'frames';
var topRightSplitId = 'schemas';
var bottomLeftSplitId = 'control';
var bottomRightSplitId = 'semantics-examples';

function createHSplitter() {
  $('#'+hSplitterId).height($('#content').height() - 50);

  if ($.fn.splitter) {

	$(window).resize(function() {
		$('#'+hSplitterId).height($('#content').height() - 50);
	});

    $('#'+hSplitterId).bind('resize', function(e) {
		  var resizeEvt;
	      clearTimeout(resizeEvt);
	      resizeEvt = setTimeout(function() {
	        	$('#'+topVSplitterId).trigger('resize', $('#'+topLeftSplitId).width());
	            $('#'+bottomVSplitterId).trigger('resize', $('#'+bottomLeftSplitId).width()+7);
	        }, 50);
		  e.stopPropagation();
	});

    $('#'+topSplitId).bind('resize', function(e) {
    	$('#'+topVSplitterId).height($('#'+topSplitId).height());
    	$('#'+topVSplitterId).children().each(function () {
    		$(this).height($('#'+topSplitId).height() - 7);
    	});

    	$('#'+bottomVSplitterId).height($('#'+bottomSplitId).height());
    	$('#'+bottomVSplitterId).children().each(function () {
    		$(this).height($('#'+bottomSplitId).height() - 7);
    	});
        e.stopPropagation();
    });
    $('#'+bottomSplitId).bind('resize', function(e) {
      e.stopPropagation();
    });
    $('#'+hSplitterId).splitter({
      type: "h",
      minTop: 200,
      minBottom: 100,
      sizeBottom: 170,
      resizeToWidth: true,
      outline: true
    });
  }
}

function createVTopSplitter() {
  var w=$('#'+topVSplitterId).width();

  $('#'+topVSplitterId).height(2*$('#content').height()/3);

  if ($.fn.splitter) {
    $('#'+topLeftSplitId).bind('resize', function(e) {
    	$('#'+topVSplitterId).height($('#'+topSplitId).height());
    	$('#'+topVSplitterId).children().each(function () {
    		$(this).height($('#'+topSplitId).height() - 7);
    	});
    	$('#'+topRightSplitId).width($('#'+topRightSplitId).width() - 20);
        e.stopPropagation();
    });
    $('#'+topRightSplitId).bind('resize', function(e) {
      e.stopPropagation();
    });
    $('#'+topVSplitterId).splitter({
      type: "v",
      minLeft: 50,
      sizeLeft: w/2,
      resizeToWidth: true,
      outline: true
    });
  }
}

function createVBottomSplitter() {
  var w=$('#'+bottomVSplitterId).width();
  $('#'+bottomVSplitterId).height($('#content').height()/3);
  if ($.fn.splitter) {
    $('#'+bottomLeftSplitId).bind('resize', function(e) {
    	$('#'+bottomVSplitterId).height($('#'+bottomSplitId).height());
    	$('#'+bottomVSplitterId).children().each(function () {
    		$(this).height($('#'+bottomSplitId).height()-7);
    	});

    	$('#'+bottomLeftSplitId).width($('#'+bottomLeftSplitId).width() - 7);
    	$('#'+bottomRightSplitId).width($('#'+bottomRightSplitId).width() - 20);
        e.stopPropagation();
    });
    $('#'+bottomRightSplitId).bind('resize', function(e) {
      e.stopPropagation();
    });
    $('#'+bottomVSplitterId).splitter({
      type: "v",
      sizeLeft: w/3,
      minLeft: 200,
      resizeToWidth: true,
      outline: true
    });
  }
}