semantics_splitters.js 3.26 KB
/////////////////////////// Splitters ///////////////////////////

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($('#right').height() - 70);

  if ($.fn.splitter) {

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

    $('#'+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*$('#right').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($('#right').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
    });
  }
}