web/static/res/js/popUp.js
author Edwin Razafimahatratra <edwin@robotalismsoft.com>
Wed, 16 Jan 2013 08:26:00 +0100
changeset 78 8c3f0b94d056
child 93 7c37aaa2a8ae
permissions -rw-r--r--
big commit after problems
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
78
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
     1
function toggle(div_id)
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
     2
{
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
     3
	var el = document.getElementById(div_id);
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
     4
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
     5
	else {el.style.display = 'none';}
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
     6
}
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
     7
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
     8
var popupOn = false;
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
     9
function popupPosition(windowname, contantId)
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    10
{
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    11
	if (!popupOn) {
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    12
		return;
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    13
	}
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    14
	var blanket_height = $("#" + contantId).height();
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    15
	var window_width = $("#" + contantId).width();
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    16
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    17
	var blanket = $("#blanket");
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    18
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    19
	var popup = $("#"+windowname);
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    20
	var popupHeight = popup.height();
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    21
	var popupTop = (blanket_height - popupHeight) / 2;
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    22
	popup.css({"top" : + popupTop +'px'});
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    23
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    24
	var popupWidth = popup.width();
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    25
	var popupLeft = (window_width - popupWidth) / 2;
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    26
	popup.css({"left" : + popupLeft +'px'});	
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    27
}
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    28
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    29
function popup(windowname, contantId)
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    30
{
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    31
	popupOn = !popupOn;
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    32
	popupPosition(windowname, contantId);
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    33
	toggle('blanket');
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    34
	toggle(windowname);
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    35
}