📄 ig_webchart_browser.js
字号:
this.SetYScrollContainerAdjusted(obj, y, vSC);
else
this.SetY(obj, y);
}
this.GetVScrolledContainer = function(obj)
{
if (obj.scrollTop > 0 && obj.tagName != 'BODY')
return obj;
else if (obj.offsetParent != null)
return this.GetVScrolledContainer(obj.offsetParent);
else
return null;
}
this.GetHScrolledContainer = function(obj)
{
if (obj.scrollLeft > 0 && obj.tagName != 'BODY')
return obj;
else if (obj.offsetParent != null)
return this.GetHScrolledContainer(obj.offsetParent);
else
return null;
}
this.SetXScrollContainerAdjusted = function(obj, x, container)
{
this.SetX(obj, x + container.scrollLeft);
}
this.SetYScrollContainerAdjusted = function(obj, y, container)
{
this.SetY(obj, y + container.scrollTop);
}
// endregion
// where = beforeBegin,afterBegin,beforeEnd,afterEnd
this.InsertHTML = function(obj,html,where)
{
if (this.IsOpera) return;
if (obj.insertAdjacentHTML)
{
obj.insertAdjacentHTML(where,html);
return;
}
if (this.IsNetscape)
{
this.WriteHTML(obj,html);
return;
}
// Mozilla
var ref = obj.ownerDocument.createRange();
ref.setStartBefore(obj);
var fragment = ref.createContextualFragment(html);
this.DOMInsertObj(obj,where,fragment);
}
this.DOMInsertObj = function(obj, where, node)
{
switch (where)
{
case 'beforeBegin':
obj.parentNode.insertBefore(node,obj)
break;
case 'afterBegin':
obj.insertBefore(node,obj.firstChild);
break;
case 'beforeEnd':
obj.appendChild(node);
break;
case 'afterEnd':
if (obj.nextSibling)
{
obj.parentNode.insertBefore(node,obj.nextSibling);
}
else
{
obj.parentNode.appendChild(node)
}
break;
}
}
// Common Global Infrastructure related begin
ID2OBJECT["IGB"] = this;
this.Listener = new Array();
this.AddListener = function(type, function_ref)
{
this.Listener[type] = function_ref;
}
// Common Global Infrastructure related end
this.CurrentX = 0;
this.CurrentY = 0;
// Common golbal infrastructure related. -WORK IN PROGRESS.
this.GlobalHandleMouseMove = function(evt)
{
if (this.IsNetscape4Plus)
{
this.CurrentX=evt.pageX;
this.CurrentY=evt.pageY;
}
else if (this.IsNetscape6)
{
this.CurrentX=evt.clientX;
this.CurrentY=evt.clientY;
}
else if (this.IsIE5)
{
this.CurrentX=event.clientX;
this.CurrentY=event.clientY;
}
IGProcessEventsObjects("onmousemove", this);
return false;
}
// Gets the function name from the function reference.
this.FunctionName = function(f)
{
if (f==null)
{
return "annonymous";
}
var s=f.toString().match(/function (\w*)/)[1];
if((s==null)|| (s.length==0)) return "annonymous";
return s;
}
// DecodeArguments, spilt and url-decode it.
// string is split at "&" and url decoded, all the items are put in an array.
this.DecodeArguments=function(inputString)
{
var splitArray = inputString.split('&');
for (i=0; i<splitArray.length; i++) splitArray[i] = unescape(splitArray[i]);
return splitArray;
}
}
// Util objects
function IGRectangle(x, y, width, height)
{
this.X=x;
this.Y=y;
this.Width=width;
this.Height=height;
this.Inside = function(x,y)
{
return (x >=this.X && y >= this.Y && x <=(this.X+this.Width) && y <=(this.Y+this.Height));
}
}
function IGPoint(x, y)
{
this.X = x;
this.Y = y;
}
// Common Global Infrastructure begin
// TODO: this requires work. Either the event handling can be replaced and or modified to suit better
// Please use "apply" and Delegate Object instances or reference to handle this -KV.
// Declare global variable
var IGB = new IGBrowser();
function IGProcessEventsObjects(type, sender_object)
{
if (eval("sender_object.Listener"))
{
var function_ref = sender_object.Listener[type];
if (function_ref != null)
{
function_ref(type, null, sender_object);
}
}
}
function IGProcessEvents(type, sender_element)
{
var sender_object = ID2OBJECT[sender_element.id];
IGBubbleEvent(type, sender_element, sender_object);
if (eval("sender_object.Listener"))
{
var function_ref = sender_object.Listener[type];
if (function_ref != null)
{
function_ref(type, sender_element, sender_object);
}
}
}
function IGBubbleEvent(type, sender_element, sender_object)
{
if (eval("sender_object."+type))
{
if (eval("sender_object."+type+"(sender_element, sender_object)"))
{
var parent_ref = sender_object.Parent;
if (parent_ref != null)
{
IGBubbleEvent(type, sender_element, parent_ref);
}
}
}
}
// Common Global Infrastructure related end
// Repeating infrastructure related. This used to implement repeating functionality in controls such as scrollbar and fader.
// Please note that this repeating logic can only handle one repeating at a time. Call to Cancel repeating will cancel any
// other repeating in progress. This logic can be extended to handle more than one repeating but since chart uses are limited
// not implemented. -KV
var RepeatingDelegate=null;
var DelegateParameter=null;
var DelegateeObject=null;
var TimerId= null;
// Linear decay repeating
// ^
// | unit: msec
// 70 +
// | \
// | \
// 5 + \____
// +-----+---->
// 0 552
function GetDelay(nextTimeOut)
{
if (nextTimeOut == -1)
{
nextTimeOut = 70;
}
else
{
nextTimeOut-=5;
if (nextTimeOut<5) nextTimeOut = 5;
}
return nextTimeOut;
}
// Repeating handler, called upon each timeout
function RepeatingHandler(nextTimeOut)
{
nextTimeOut = GetDelay(nextTimeOut);
TimerId=setTimeout("RepeatingHandler("+nextTimeOut+")", nextTimeOut);
if (RepeatingDelegate!=null)
{
RepeatingDelegate.apply(DelegateeObject, DelegateParameter);
}
}
// setup start and stop repeating
function Repeating(trueToStartfalseToEnd, delegate, parameters, ThisObject)
{
if (trueToStartfalseToEnd == true)
{
RepeatingDelegate = delegate;
DelegateParameter = parameters;
DelegateeObject = ThisObject;
RepeatingHandler(-1);
}
else
{
if (TimerId)
{
clearTimeout(TimerId);
TimerId = null;
}
RepeatingDelegate = null;
DelegateParameter = null;
}
}
// Fader class is used to create fading effect on given element.
// This animates the Opacity Style in given interval.
// Very Generic Object can be used on pretty much any element ref.
function Fader()
{
// Common Global Infrastructure related begin
ID2OBJECT[this.ID]= this; // save id's ref.
this.Parent = null; // for parent child relationship
this.Listener = new Array();
this.AddListener = function(type, function_ref)
{
// nothing supported yet
}
// Common Global Infrastructure related end
// Private variables
this.FaderOpacity = 0;
this.FaderStep=function(id_ref, min, max, delta)
{
if( (this.FaderOpacity<=max) && (this.FaderOpacity>=min) )
{
this.FaderOpacity += delta;
if (IGB.IsIE4 || IGB.IsIE5) id_ref.style.filter="alpha(opacity="+this.FaderOpacity+")";
if (IGB.IsNetscape6) id_ref.style.MozOpacity=this.FaderOpacity/100;
}
else
{
Repeating(false);
}
}
// Starts the fader
// animates the opacity of an element from [min..max] with delta.
// make sure delta is not equal to zero other wise it will never stop repeating
this.Start=function(id_ref, min, max, delta)
{
this.FaderOpacity = min;
Repeating(true, this.FaderStep, [id_ref, min, max, delta], this);
}
this.End=function()
{
Repeating(false);
}
}
/// Bounce event to right object.
/// event - object
/// id - string
/// func_name - string
function Bounce(evt, id, func_name, paramArray)
{
var this_ref = ID2OBJECT[id];
var fn = func_name;
if (this_ref)
{
if (fn)
{
fn = func_name;
}
else
{
fn = "on"+evt.type;
}
eval("this_ref."+fn+"(evt, id, paramArray)");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -