web/static/res/js/popup.js
author ymh <ymh.work@gmail.com>
Tue, 12 Feb 2013 10:54:34 +0100
changeset 134 678b07d351ef
parent 99 44647228cfb9
permissions -rw-r--r--
Added tag V01.25 for changeset fe9ca5cd905e
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;
93
7c37aaa2a8ae netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 78
diff changeset
     9
var playOnClose = false;
78
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    10
function popupPosition(windowname, contantId)
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    11
{
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    12
	if (!popupOn) {
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    13
		return;
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    14
	}
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    15
	var blanket_height = $("#" + contantId).height();
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    16
	var window_width = $("#" + contantId).width();
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    17
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    18
	var blanket = $("#blanket");
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    19
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    20
	var popup = $("#"+windowname);
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    21
	var popupHeight = popup.height();
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    22
	var popupTop = (blanket_height - popupHeight) / 2;
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    23
	popup.css({"top" : + popupTop +'px'});
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    24
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    25
	var popupWidth = popup.width();
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    26
	var popupLeft = (window_width - popupWidth) / 2;
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    27
	popup.css({"left" : + popupLeft +'px'});	
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
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    30
function popup(windowname, contantId)
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    31
{
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    32
	popupOn = !popupOn;
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    33
	popupPosition(windowname, contantId);
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    34
	toggle('blanket');
8c3f0b94d056 big commit after problems
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents:
diff changeset
    35
	toggle(windowname);
93
7c37aaa2a8ae netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 78
diff changeset
    36
}
7c37aaa2a8ae netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 78
diff changeset
    37
7c37aaa2a8ae netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 78
diff changeset
    38
function openClosePopup() {
7c37aaa2a8ae netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 78
diff changeset
    39
	if (popupOn) {
7c37aaa2a8ae netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 78
diff changeset
    40
		if (!incPlayer.popSeq.playing && playOnClose) {
7c37aaa2a8ae netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 78
diff changeset
    41
			incPlayer.ctrlPlay();
7c37aaa2a8ae netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 78
diff changeset
    42
			playOnClose = false;
7c37aaa2a8ae netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 78
diff changeset
    43
		}
7c37aaa2a8ae netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 78
diff changeset
    44
	} else if (incPlayer.popSeq.playing) {
7c37aaa2a8ae netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 78
diff changeset
    45
		incPlayer.ctrlPlay();
7c37aaa2a8ae netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 78
diff changeset
    46
		playOnClose = true;
7c37aaa2a8ae netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 78
diff changeset
    47
	}
7c37aaa2a8ae netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 78
diff changeset
    48
	popup('popUpDiv', 'content');
7c37aaa2a8ae netoyage update du rep static
Edwin Razafimahatratra <edwin@robotalismsoft.com>
parents: 78
diff changeset
    49
}