forked from science-ation/science-ation
Remove the old translationsdropdowns
This commit is contained in:
parent
bef9c279ec
commit
dd51217bc0
@ -1,249 +0,0 @@
|
||||
<?
|
||||
/*
|
||||
This file is part of the 'Science Fair In A Box' project
|
||||
SFIAB Website: http://www.sfiab.ca
|
||||
|
||||
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
|
||||
Copyright (C) 2005 James Grant <james@lightbox.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation, version 2.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
require_once("ajax.inc.php");
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
|
||||
var queryInProgress=false;
|
||||
var translateOpen=false;
|
||||
var translationObject;
|
||||
var langstr="<? foreach($config['languages'] AS $l=>$ln){ $lstr.="$l/"; } echo substr($lstr,0,-1)?>";
|
||||
|
||||
var jsTranslateLangs=new Array();
|
||||
<?
|
||||
$x=0;
|
||||
foreach($config['languages'] AS $l=>$ln)
|
||||
{
|
||||
if($l=="en")continue;
|
||||
echo "jsTranslateLangs[$x]=\"$l\";\n";
|
||||
$x++;
|
||||
}
|
||||
?>
|
||||
|
||||
function selectVisibility(vis) {
|
||||
//we'll always have form0=translationdropdownform, form1=langselectform, form2...infinity=forms on the page
|
||||
for(x=2;x<document.forms.length;x++) {
|
||||
var frm=document.forms[x];
|
||||
for(y=0;y<frm.elements.length;y++) {
|
||||
var e=frm.elements[y];
|
||||
if(e.type=="select-one")
|
||||
e.style.visibility=vis;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getTranslations(o)
|
||||
{
|
||||
var objItem=document.getElementById(o);
|
||||
var url="<?=$config['SFIABDIRECTORY']?>/admin/gettranslation.php?str="+escape(objItem.value);
|
||||
|
||||
if(!queryInProgress)
|
||||
{
|
||||
queryInProgress=true;
|
||||
http.open("GET", url , true);
|
||||
http.onreadystatechange = handleResponse;
|
||||
http.send(null);
|
||||
}
|
||||
}
|
||||
|
||||
function handleResponse()
|
||||
{
|
||||
try {
|
||||
|
||||
if(http.readyState==4)
|
||||
{
|
||||
queryInProgress=false;
|
||||
var d=document.getElementById('translationdropdown');
|
||||
// alert(completeField);
|
||||
|
||||
try {
|
||||
results = http.responseText.split('\n');
|
||||
var num=results.length;
|
||||
|
||||
for(i=0;i<results.length;i++)
|
||||
{
|
||||
if(!results[i]){ num--; continue; }
|
||||
|
||||
line = results[i].split(':');
|
||||
//line[0] has "en" or "fr" or the lang code
|
||||
//line[1] has the actual translation for that language
|
||||
objInput=document.getElementById('translation['+line[0]+']');
|
||||
if(line[1])
|
||||
{
|
||||
//alert(objInput);
|
||||
objInput.value=line[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
objInput.value="";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
function translateButton(o)
|
||||
{
|
||||
document.write("<a href=\"#\" onclick=\"return translateDropdown('"+o+"')\"><?=i18n("translations")?></a>");
|
||||
}
|
||||
function translateDropdown(o)
|
||||
{
|
||||
translationObject=document.getElementById(o);
|
||||
var d=document.getElementById('translationdropdown');
|
||||
if(translateOpen) {
|
||||
d.style.visibility="hidden";
|
||||
selectVisibility("visible");
|
||||
}
|
||||
else
|
||||
{
|
||||
getTranslations(o);
|
||||
objItem=translationObject;
|
||||
|
||||
var tagheight=objItem.offsetHeight;
|
||||
var tagwidth=objItem.offsetWidth+75;
|
||||
|
||||
//alert('tagheight='+tagheight+' tagwidth='+tagwidth);
|
||||
|
||||
var intx=0;
|
||||
var inty=0;
|
||||
|
||||
do
|
||||
{
|
||||
intx+=objItem.offsetLeft;
|
||||
inty+=objItem.offsetTop;
|
||||
objParent=objItem.offsetParent.tagName;
|
||||
objItem=objItem.offsetParent;
|
||||
} while(objParent!="BODY");
|
||||
|
||||
d.style.top=inty+tagheight+"px";
|
||||
d.style.left=(intx-75)+"px";
|
||||
d.style.width=(tagwidth)+"px";
|
||||
// d.style.height=dropdownheight+"px";
|
||||
d.style.visibility="visible";
|
||||
|
||||
oButton=document.getElementById('buttonsavetranslations');
|
||||
oButton.value="<?=i18n("Save Translations")?>";
|
||||
|
||||
selectVisibility("hidden");
|
||||
|
||||
}
|
||||
translateOpen=!translateOpen;
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
function savetranslations()
|
||||
{
|
||||
var url="<?=$config['SFIABDIRECTORY']?>/admin/settranslation.php?str="+escape(translationObject.value);
|
||||
var x;
|
||||
for(x=0;x<jsTranslateLangs.length;x++)
|
||||
{
|
||||
oTmp=document.getElementById('translation['+jsTranslateLangs[x]+']');
|
||||
url+="&"+jsTranslateLangs[x]+"="+escape(oTmp.value);
|
||||
}
|
||||
oButton=document.getElementById('buttonsavetranslations');
|
||||
oButton.value="<?=i18n("Saving translations...")?>";
|
||||
|
||||
if(!queryInProgress)
|
||||
{
|
||||
queryInProgress=true;
|
||||
http.open("GET", url , true);
|
||||
http.onreadystatechange = handleSaveResponse;
|
||||
http.send(null);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function handleSaveResponse()
|
||||
{
|
||||
try {
|
||||
|
||||
if(http.readyState==4)
|
||||
{
|
||||
queryInProgress=false;
|
||||
var d=document.getElementById('translationdropdown');
|
||||
|
||||
oButton=document.getElementById('buttonsavetranslations');
|
||||
oButton.value="<?=i18n("Translations Saved")?>";
|
||||
|
||||
setTimeout("translateDropdown('dummy');",500); //it doesnt matter what obj we use, because we're just clearing it anyways
|
||||
|
||||
//who cares what happens, we're done thats all we care about
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<?
|
||||
$num=count($config['languages'])-1; //subtract 1 for english
|
||||
$divheight=($num*25)+50;
|
||||
?>
|
||||
<style type="text/css">
|
||||
.translationdropdown
|
||||
{
|
||||
position: absolute;
|
||||
z-index: 100;
|
||||
overflow: auto;
|
||||
width: 300px;
|
||||
background-color: #669966;
|
||||
visibility: hidden;
|
||||
border: 0px;
|
||||
top: 0px;
|
||||
left:0px;
|
||||
width:300px;
|
||||
height:<?=$divheight?>px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
</style>
|
||||
<div class="translationdropdown" name="translationdropdown" id="translationdropdown">
|
||||
<form name="translationform" method="get">
|
||||
<table cellspacing=0 cellpadding=0 border=0 style="width: 99%; font-size: 0.8em;">
|
||||
<?
|
||||
foreach($config['languages'] AS $l=>$ln)
|
||||
{
|
||||
if($l=="en") continue;
|
||||
echo "<tr><td style=\"width: 75px;\">$ln:</td><td><input type=\"text\" style=\"width: 100%;\" id=\"translation[$l]\" name=\"translation[$l]\"></td></tr>";
|
||||
}
|
||||
echo "</table>\n";
|
||||
echo "<input type=\"button\" id=\"buttonsavetranslations\" onclick=\"return savetranslations()\" value=\"".i18n("Save Translations")."\">";
|
||||
?>
|
||||
</form>
|
||||
</div>
|
@ -1,112 +0,0 @@
|
||||
<?
|
||||
/*
|
||||
This file is part of the 'Science Fair In A Box' project
|
||||
SFIAB Website: http://www.sfiab.ca
|
||||
|
||||
Copyright (C) 2009 James Grant <james@lightbox.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation, version 2.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
|
||||
var currentLang='<?=$_SESSION['lang']?>';
|
||||
var translateLangs=new Array();
|
||||
<?
|
||||
$x=0;
|
||||
foreach($config['languages'] AS $l=>$ln) {
|
||||
if($l==$_SESSION['lang']) continue;
|
||||
echo "translateLangs[$x]=\"$l\";\n";
|
||||
$x++;
|
||||
}
|
||||
?>
|
||||
|
||||
$(document).ready(function() {
|
||||
$(".translatable").each( function(i) {
|
||||
$(this).after(" <a href=\"#translate\"><?=i18n("translations")?></a>");
|
||||
});
|
||||
|
||||
$("[href*=#translate]").click(function() {
|
||||
// alert(this.href);
|
||||
// $("#translationdialog").dialog({ buttons: { "Save": function() { $(this).dialog("close");}}, modal: true });
|
||||
// alert($(this).prev().attr('id'));
|
||||
popup_translator($(this).prev().val());
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#translation_editor").dialog({
|
||||
bgiframe: true, autoOpen: false,
|
||||
modal: true, resizable: false,
|
||||
draggable: false
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
function popup_translator(str) {
|
||||
var w = (document.documentElement.clientWidth * 0.8);
|
||||
var h = (document.documentElement.clientHeight * 0.4);
|
||||
|
||||
$('#translation_editor').dialog('option','width',w);
|
||||
$('#translation_editor').dialog('option','height',h);
|
||||
$('#translation_editor').dialog('option','buttons',{ "<?=i18n("Save")?>": function() { save_translations(); },
|
||||
"<?=i18n("Cancel")?>": function(){ $(this).dialog("close");}});
|
||||
$('#translation_editor').dialog('open');
|
||||
|
||||
$('#translate_str').html(str);
|
||||
$('#translate_str_hidden').val(str);
|
||||
|
||||
$.getJSON("<?=$config['SFIABDIRECTORY']?>/admin/gettranslation.php?str="+escape(str),function(json){
|
||||
for(var i=0;i<translateLangs.length;i++) {
|
||||
$("#translate_"+translateLangs[i]).val(json[translateLangs[i]]);
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function save_translations() {
|
||||
$.post("<?=$config['SFIABDIRECTORY']?>/admin/settranslation.php",
|
||||
$("#translationform").serialize(),
|
||||
function(data) {
|
||||
$('#translation_editor').dialog('close');
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
//this is here only to catch any missing translateButton()'s
|
||||
function translateButton(o) {
|
||||
// alert('tell james there is a translateButton he missed');
|
||||
}
|
||||
|
||||
</script>
|
||||
<div style="display: none" title="<?=i18n("Translation Editor")?>" id="translation_editor">
|
||||
<form id="translationform" onsubmit="return save_translations()">
|
||||
<input type="hidden" id="translate_str_hidden" name="translate_str_hidden">
|
||||
<table style="width: 100%;">
|
||||
<?
|
||||
echo "<tr><td align=\"right\" width=\"100\">".$config['languages'][$config['default_language']].":</td><td><span id=\"translate_str\" style=\"font-weight: bold;\"></span></td></tr>\n";
|
||||
echo "<tr><td colspan=\"2\"><hr /></td></tr>\n";
|
||||
|
||||
|
||||
foreach($config['languages'] AS $l=>$ln) {
|
||||
if($l==$config['default_language']) continue;
|
||||
echo "<tr><td align=\"right\">$ln</td><td><input style=\"width: 100%;\" type=\"text\" name=\"translate_{$l}\" id=\"translate_{$l}\"></td></tr>\n";
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user