Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…912cdd6b-5c7d-d5a7-a2ba-d0f0cdb91641
  • Loading branch information
FayCross committed May 2, 2012
1 parent 5ff8a0c commit 5a2eb63
Showing 1 changed file with 183 additions and 7 deletions.
190 changes: 183 additions & 7 deletions modules/xerte/play.php
Expand Up @@ -35,13 +35,189 @@ function show_template($row_play){
<title><?PHP echo XERTE_PREVIEW_TITLE; ?></title>
<script type="text/javascript">
function enableTTS(){
if (navigator.appName.indexOf("Microsoft") != -1){
VoiceObj = new ActiveXObject("Sapi.SpVoice");
}
}
function openWindow(params){
window.open(params.url,'xerte_window',"status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,left=" + String((screen.width / 2) - (params.width / 2)) + ",top=" + String((screen.height / 2) - (params.height / 2)) + ",height=" + params.height + ",width=" + params.width);
}
if (navigator.appName.indexOf("Microsoft") != -1){
VoiceObj = new ActiveXObject("Sapi.SpVoice");
}
}

function openWindow(params){
if (params.type == "media") {
var src = params.url + '?media=../' + params.media + ',transcript=../' + params.transcript + ',img=../' + params.img;
window.open(src,'xerte_window',"status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,left=" + String((screen.width / 2) - (params.width / 2)) + ",top=" + String((screen.height / 2) - (params.height / 2)) + ",height=" + params.height + ",width=" + params.width);
} else {
window.open(params.url,'xerte_window',"status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,left=" + String((screen.width / 2) - (params.width / 2)) + ",top=" + String((screen.height / 2) - (params.height / 2)) + ",height=" + params.height + ",width=" + params.width);
}
}

var popupInfo = new Array();
var stageW;
var stageH;
var screenSize;

function makePopUp(params) {
//kill any existing popups
var popup = document.getElementById("popup");
var parent = document.getElementById("popup_parent");

if (popup != null) {
parent.removeChild(popup);
}

//make the div and style it
var create_div = document.createElement("DIV");
create_div.id = params.id;
create_div.style.position = "absolute";
create_div.style.background = params.bgColour;
if (params.borderColour != "none") {
create_div.style.border = "1px solid " + params.borderColour;
}

stageW = params.width;
stageH = params.height;
if (stageW == 1600 && stageH == 1200) {
stageW = document.getElementsByTagName('body')[0].clientWidth;
stageH = document.getElementsByTagName('body')[0].clientHeight;
}
if (screenSize == "full screen") {
calcStageSize();
}

// save info about popup to use if screen resized
var index = popupInfo.length;
popupInfo[index] = new Array();
popupInfo[index][0] = params.id;
popupInfo[index][1] = params.type;
popupInfo[index][2] = params.calcW;
popupInfo[index][3] = params.calcH;
popupInfo[index][4] = params.calcX;
popupInfo[index][5] = params.calcY;

if (screenSize == "fill window") {
create_div.style.width = params.calcW + "%";
create_div.style.height = params.calcH + "%";
create_div.style.left = params.calcX + "%";
create_div.style.top = params.calcY + "%";
} else {
create_div.style.width = calcPopupSize("width", index) + "px";
create_div.style.height = calcPopupSize("height", index) + "px";
create_div.style.left = calcPopupSize("x", index) + "px";
create_div.style.top = calcPopupSize("y", index) + "px";
}

if (params.type == 'div') {
create_div.innerHTML = params.src;
} else {
var iframe_create_div = document.createElement("IFRAME");
iframe_create_div.id = "i" + params.id;
iframe_create_div.name = "i" + params.id;
iframe_create_div.src = params.src;
if (params.type == 'jmol') {
iframe_create_div.src += ',width=' + calcPopupSize("width", index) + ',height=' + calcPopupSize("height", index);
}
iframe_create_div.style.width = "100%";
iframe_create_div.style.height = "100%";
iframe_create_div.frameBorder = 'no';
create_div.appendChild(iframe_create_div);
}

//finally append the div
parent.appendChild(create_div);
}

function killPopUp() {
var parent = document.getElementById("popup_parent");
if (parent.hasChildNodes()) {
while (parent.childNodes.length >= 1) {
parent.removeChild(parent.firstChild);
popupInfo.splice(0, popupInfo.length);
}
}
}

function calcPopupSize(type, index) {
var num;
if (type == "width") {
num = stageW / 100 * popupInfo[index][2];
} else if (type == "height") {
num = stageH / 100 * popupInfo[index][3];
} else if (type == "x") {
num = stageW / 100 * popupInfo[index][4];
} else if (type == "y") {
num = stageH / 100 * popupInfo[index][5];
}
return num;
}

function calcStageSize() {
if (stageH / stageW != 0.75) {
var ratio = stageH / stageW;
if (ratio > 0.75) {
stageH = stageW * 0.75;
} else {
stageW = stageH / 0.75;
}
}
}

function resizePopup(type, width, height) {
if (screenSize != type && !(screenSize == undefined && type == "default")) {
var parent = document.getElementById("popup_parent");
if (parent.hasChildNodes()) {
if (type == "fill window") {
for (i=0; i<popupInfo.length; i++) {
id = parent.childNodes[i].id;
document.getElementById(id).style.width = popupInfo[i][2] + "%";
document.getElementById(id).style.height = popupInfo[i][3] + "%";
document.getElementById(id).style.left = popupInfo[i][4] + "%";
document.getElementById(id).style.top = popupInfo[i][5] + "%";
if (popupInfo[i][1] == 'jmol') {
stageW = document.getElementsByTagName('body')[0].clientWidth;
stageH = document.getElementsByTagName('body')[0].clientHeight;
document.getElementById("ipopup"+i).contentWindow.resize(calcPopupSize("width", i), calcPopupSize("height", i));
//window.frames["ipopup"+i].resize(calcPopupSize("width", i), calcPopupSize("height", i));
}
}
} else {
if (type == "full screen") {
stageW = document.getElementsByTagName('body')[0].clientWidth;
stageH = document.getElementsByTagName('body')[0].clientHeight;
calcStageSize();
} else {
stageW = width;
stageH = height;
}
for (i=0; i<popupInfo.length; i++) {
id = parent.childNodes[i].id;
document.getElementById(id).style.width = calcPopupSize("width", i) + "px";
document.getElementById(id).style.height = calcPopupSize("height", i) + "px";
document.getElementById(id).style.left = calcPopupSize("x", i) + "px";
document.getElementById(id).style.top = calcPopupSize("y", i) + "px";
if (popupInfo[i][1] == 'jmol') {
document.getElementById("ipopup"+i).contentWindow.resize(calcPopupSize("width", i), calcPopupSize("height", i));
//window.frames["ipopup"+i].resize(calcPopupSize("width", i), calcPopupSize("height", i));
}
}
}
}
}
screenSize = type;
}

function windowResized() {
var parent = document.getElementById("popup_parent");
if (parent.hasChildNodes() && screenSize == "full screen") {
stageW = document.getElementsByTagName('body')[0].clientWidth;
stageH = document.getElementsByTagName('body')[0].clientHeight;
calcStageSize();
for (i=0; i<popupInfo.length; i++) {
id = parent.childNodes[i].id;
document.getElementById(id).style.width = calcPopupSize("width", i) + "px";
document.getElementById(id).style.height = calcPopupSize("height", i) + "px";
document.getElementById(id).style.left = calcPopupSize("x", i) + "px";
document.getElementById(id).style.top = calcPopupSize("y", i) + "px";
}
}
}
</script>
<SCRIPT LANGUAGE=JavaScript1.1>
<!--
Expand Down

0 comments on commit 5a2eb63

Please sign in to comment.