Add JS files
This commit is contained in:
164
modules/EcmDocs/helper.js
Executable file
164
modules/EcmDocs/helper.js
Executable file
@@ -0,0 +1,164 @@
|
||||
function showdescription(id,title,desc,minus,object)
|
||||
{
|
||||
if(!minus)minus=0;
|
||||
var sum=17-minus;
|
||||
document.getElementById("desc").style.display="inline";
|
||||
document.getElementById("desc-title").innerHTML=title;
|
||||
document.getElementById("desc-desc").innerHTML=desc;
|
||||
posy=findPosY(object)+sum;
|
||||
posx=findPosX(object);
|
||||
moveDiv(document.getElementById("desc"),posy,posx);
|
||||
}
|
||||
function hidedescription()
|
||||
{
|
||||
document.getElementById("desc").style.display="none";
|
||||
}
|
||||
function mintajaxget(url,tag)
|
||||
{
|
||||
var req=mint.Request();
|
||||
req.Set('timeout',10000000);
|
||||
req.Set('retryNum',0);
|
||||
req.OnLoading=function(){$(tag).innerHTML='<img src="themes/default/images/loading.gif" border="0">';}
|
||||
req.OnSuccess = function(){if($(tag).type=='text'){if(this.responseText!="")$(tag).value=this.responseText;}else{if(this.responseText!="")$(tag).innerHTML=this.responseText;}}
|
||||
req.Send(url,tag);
|
||||
|
||||
}
|
||||
function mintajaxpost(url,tag,form)
|
||||
{
|
||||
var req=mint.Request();
|
||||
req.OnSuccess=function(){$(tag).innerHTML=this.responseText;}
|
||||
req.OnLoading=function(){$(tag).innerHTML='<img src="themes/default/images/loading.gif" border="0">';}
|
||||
req.SendForm(form);
|
||||
}
|
||||
function moveDiv(obj, mvTop, mvLeft) {
|
||||
obj.style.position = "absolute";
|
||||
obj.style.top = mvTop;
|
||||
obj.style.left = mvLeft;
|
||||
}
|
||||
function getPos(inputElement) {
|
||||
var coords = new Object();
|
||||
coords.x = 0;
|
||||
coords.y = 0;
|
||||
try {
|
||||
targetElement = inputElement;
|
||||
if(targetElement.x && targetElement.y) {
|
||||
coords.x = targetElement.x;
|
||||
coords.y = targetElement.y;
|
||||
} else {
|
||||
if(targetElement.offsetParent) {
|
||||
coords.x += targetElement.offsetLeft;
|
||||
coords.y += targetElement.offsetTop;
|
||||
while(targetElement = targetElement.offsetParent) {
|
||||
coords.x += targetElement.offsetLeft;
|
||||
coords.y += targetElement.offsetTop;
|
||||
}
|
||||
} else {
|
||||
//alert("Could not find any reference for coordinate positioning.");
|
||||
}
|
||||
}
|
||||
return coords;
|
||||
} catch(error) {
|
||||
//alert(error.msg);
|
||||
return coords;
|
||||
}
|
||||
}
|
||||
|
||||
function findPosX(obj)
|
||||
{
|
||||
var curleft = 0;
|
||||
if(obj.offsetParent)
|
||||
while(1)
|
||||
{
|
||||
curleft += obj.offsetLeft;
|
||||
if(!obj.offsetParent)
|
||||
break;
|
||||
obj = obj.offsetParent;
|
||||
}
|
||||
else if(obj.x)
|
||||
curleft += obj.x;
|
||||
return curleft;
|
||||
//return getPos(obj).x;
|
||||
}
|
||||
|
||||
function findPosY(obj)
|
||||
{
|
||||
var curtop = 0;
|
||||
if(obj.offsetParent)
|
||||
while(1)
|
||||
{
|
||||
curtop += obj.offsetTop;
|
||||
if(!obj.offsetParent)
|
||||
break;
|
||||
obj = obj.offsetParent;
|
||||
}
|
||||
else if(obj.y)
|
||||
curtop += obj.y;
|
||||
return curtop;
|
||||
//return getPos(obj).y;
|
||||
}
|
||||
function showdiv(id,div,minusy,minusx)
|
||||
{
|
||||
document.getElementById(div).style.display="inline";
|
||||
posy=findPosY(document.getElementById(id))-minusy;
|
||||
posx=findPosX(document.getElementById(id))-minusx;
|
||||
moveDiv(document.getElementById(div),posy,posx);
|
||||
}
|
||||
function hidediv(div)
|
||||
{
|
||||
document.getElementById(div).style.display="none";
|
||||
}
|
||||
function showprice(id,price,order_by,sorder)
|
||||
{
|
||||
document.getElementById('price').value=price;
|
||||
document.getElementById('product_id').value=id;
|
||||
document.getElementById('order_by').value=order_by;
|
||||
document.getElementById('sorder').value=sorder;
|
||||
document.getElementById('price-block').style.display="block";
|
||||
}
|
||||
function getPrice(id,type)
|
||||
{
|
||||
var purchase_price=document.getElementById('purchase_price_'+id).value;
|
||||
var margin_rate=document.getElementById('margin_rate_'+id).value;
|
||||
var list_price;
|
||||
|
||||
list_price=parseFloat(purchase_price)/(1-parseFloat(margin_rate)/100);
|
||||
|
||||
if(!isNaN(list_price))document.getElementById('list_price_'+id).value=roundNumber(list_price,2);
|
||||
|
||||
}
|
||||
function CurrencyFormatted(amount)
|
||||
{
|
||||
var i = parseFloat(amount);
|
||||
if(isNaN(i)) { i = 0.00; }
|
||||
var minus = '';
|
||||
if(i < 0) { minus = '-'; }
|
||||
i = Math.abs(i);
|
||||
i = parseInt((i + .005) * 100);
|
||||
i = i / 100;
|
||||
s = new String(i);
|
||||
if(s.indexOf('.') < 0) { s += '.00'; }
|
||||
if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
|
||||
s = minus + s;
|
||||
return s;
|
||||
}
|
||||
function roundN(rnum,rlength)
|
||||
{
|
||||
var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
|
||||
return newnumber;
|
||||
}
|
||||
function roundNumber(num, dec)
|
||||
{
|
||||
if(!isNaN(num))return CurrencyFormatted(roundN(parseFloat(num),dec));
|
||||
else return "";
|
||||
}
|
||||
function ShowHideBlock(id)
|
||||
{
|
||||
if(document.getElementById(id).style.display=="block")
|
||||
{
|
||||
document.getElementById(id).style.display="none"
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById(id).style.display="block"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user