📄 dhtmlxcommon.js
字号:
/*
Copyright Scand LLC http://www.scbr.com
This version of Software is free for using in GNU GPL applications. For other use or to get Professional Edition please contact info@scbr.com to obtain license
*/
/**
* @desc: xmlLoader object
* @type: private
* @param: funcObject - xml parser function
* @param: object - jsControl object
* @param: async - sync/async mode (async by default)
* @param: rSeed - enable/disable random seed ( prevent IE caching)
* @topic: 0
*/
function dtmlXMLLoaderObject(funcObject, dhtmlObject,async,rSeed){
this.xmlDoc="";
if(arguments.length==2)
this.async=true;
else
this.async=async;
this.onloadAction=funcObject||null;
this.mainObject=dhtmlObject||null;
this.waitCall=null;
this.rSeed=rSeed||false;
return this;
};
/**
* @desc: xml loading handler
* @type: private
* @param: dtmlObject - xmlLoader object
* @topic: 0
*/
dtmlXMLLoaderObject.prototype.waitLoadFunction=function(dhtmlObject){
this.check=function (){
if(dhtmlObject.onloadAction!=null){
if ((!dhtmlObject.xmlDoc.readyState)||(dhtmlObject.xmlDoc.readyState == 4)){
dhtmlObject.onloadAction(dhtmlObject.mainObject,null,null,null,dhtmlObject);
if (dhtmlObject.waitCall) { dhtmlObject.waitCall(); dhtmlObject.waitCall=null; }
dhtmlObject=null;
}
}
};
return this.check;
};
/**
* @desc: return XML top node
* @param: tagName - top XML node tag name (not used in IE, required for Safari and Mozilla)
* @type: private
* @returns: top XML node
* @topic: 0
*/
dtmlXMLLoaderObject.prototype.getXMLTopNode=function(tagName){
if (this.xmlDoc.responseXML) {
var temp=this.xmlDoc.responseXML.getElementsByTagName(tagName);
var z=temp[0];
}else
var z=this.xmlDoc.documentElement;
if (z){
this._retry=false;
return z;
}
if ((_isIE)&&(!this._retry)){
//fall back to MS.XMLDOM
var xmlString=this.xmlDoc.responseText;
this._retry=true;
this.xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
this.xmlDoc.async=false;
this.xmlDoc.loadXML(xmlString);
return this.getXMLTopNode(tagName);
}
dhtmlxError.throwError("LoadXML","Incorrect XML",[this.xmlDoc,this.mainObject]);
return document.createElement("DIV");
};
/**
* @desc: load XML from string
* @type: private
* @param: xmlString - xml string
* @topic: 0
*/
dtmlXMLLoaderObject.prototype.loadXMLString=function(xmlString){
try
{
var parser = new DOMParser();
this.xmlDoc = parser.parseFromString(xmlString,"text/xml");
}
catch(e){
this.xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
this.xmlDoc.async=this.async;
this.xmlDoc.loadXML(xmlString);
}
this.onloadAction(this.mainObject);
if (this.waitCall) { this.waitCall(); this.waitCall=null; }
}
/**
* @desc: load XML
* @type: private
* @param: filePath - xml file path
* @param: postMode - send POST request
* @param: postVars - list of vars for post request
* @topic: 0
*/
dtmlXMLLoaderObject.prototype.loadXML=function(filePath,postMode,postVars){
if (this.rSeed) filePath+=((filePath.indexOf("?")!=-1)?"&":"?")+"a_dhx_rSeed="+(new Date()).valueOf();
this.filePath=filePath;
if (window.XMLHttpRequest){
this.xmlDoc = new XMLHttpRequest();
this.xmlDoc.open(postMode?"POST":"GET",filePath,this.async);
if (postMode)
this.xmlDoc.setRequestHeader('Content-type','application/x-www-form-urlencoded');
this.xmlDoc.onreadystatechange=new this.waitLoadFunction(this);
this.xmlDoc.send(null||postVars);
}
else{
if (document.implementation && document.implementation.createDocument)
{
this.xmlDoc = document.implementation.createDocument("", "", null);
this.xmlDoc.onload = new this.waitLoadFunction(this);
this.xmlDoc.load(filePath);
}
else
{
this.xmlDoc = new ActiveXObject("Microsoft.XMLHTTP");
this.xmlDoc.open(postMode?"POST":"GET",filePath,this.async);
if (postMode) this.xmlDoc.setRequestHeader('Content-type','application/x-www-form-urlencoded');
this.xmlDoc.onreadystatechange=new this.waitLoadFunction(this);
this.xmlDoc.send(null||postVars);
}
}
};
/**
* @desc: destructor, cleans used memory
* @type: private
* @topic: 0
*/
dtmlXMLLoaderObject.prototype.destructor=function(){
this.onloadAction=null;
this.mainObject=null;
this.xmlDoc=null;
return null;
}
/**
* @desc: Call wrapper
* @type: private
* @param: funcObject - action handler
* @param: dhtmlObject - user data
* @returns: function handler
* @topic: 0
*/
function callerFunction(funcObject,dhtmlObject){
this.handler=function(e){
if (!e) e=event;
funcObject(e,dhtmlObject);
return true;
};
return this.handler;
};
/**
* @desc: Calculate absolute position of html object
* @type: private
* @param: htmlObject - html object
* @topic: 0
*/
function getAbsoluteLeft(htmlObject){
var xPos = htmlObject.offsetLeft;
var temp = htmlObject.offsetParent;
while (temp != null) {
xPos += temp.offsetLeft;
temp = temp.offsetParent;
}
return xPos;
}
/**
* @desc: Calculate absolute position of html object
* @type: private
* @param: htmlObject - html object
* @topic: 0
*/
function getAbsoluteTop(htmlObject) {
var yPos = htmlObject.offsetTop;
var temp = htmlObject.offsetParent;
while (temp != null) {
yPos += temp.offsetTop;
temp = temp.offsetParent;
}
return yPos;
}
/**
* @desc: Convert string to it boolean representation
* @type: private
* @param: inputString - string for covertion
* @topic: 0
*/
function convertStringToBoolean(inputString){ if (typeof(inputString)=="string") inputString=inputString.toLowerCase();
switch(inputString){
case "1":
case "true":
case "yes":
case "y":
case 1:
case true:
return true;
break;
default: return false;
}
}
/**
* @desc: find out what symbol to use as url param delimiters in further params
* @type: private
* @param: str - current url string
* @topic: 0
*/
function getUrlSymbol(str){
if(str.indexOf("?")!=-1)
return "&"
else
return "?"
}
function dhtmlDragAndDropObject(){
this.lastLanding=0;
this.dragNode=0;
this.dragStartNode=0;
this.dragStartObject=0;
this.tempDOMU=null;
this.tempDOMM=null;
this.waitDrag=0;
if (window.dhtmlDragAndDrop) return window.dhtmlDragAndDrop;
window.dhtmlDragAndDrop=this;
return this;
};
dhtmlDragAndDropObject.prototype.removeDraggableItem=function(htmlNode){
htmlNode.onmousedown=null;
htmlNode.dragStarter=null;
htmlNode.dragLanding=null;
}
dhtmlDragAndDropObject.prototype.addDraggableItem=function(htmlNode,dhtmlObject){
htmlNode.onmousedown=this.preCreateDragCopy;
htmlNode.dragStarter=dhtmlObject;
this.addDragLanding(htmlNode,dhtmlObject);
}
dhtmlDragAndDropObject.prototype.addDragLanding=function(htmlNode,dhtmlObject){
htmlNode.dragLanding=dhtmlObject;
}
dhtmlDragAndDropObject.prototype.preCreateDragCopy=function(e)
{
if (window.dhtmlDragAndDrop.waitDrag) {
window.dhtmlDragAndDrop.waitDrag=0;
document.body.onmouseup=window.dhtmlDragAndDrop.tempDOMU;
document.body.onmousemove=window.dhtmlDragAndDrop.tempDOMM;
return false;
}
window.dhtmlDragAndDrop.waitDrag=1;
window.dhtmlDragAndDrop.tempDOMU=document.body.onmouseup;
window.dhtmlDragAndDrop.tempDOMM=document.body.onmousemove;
window.dhtmlDragAndDrop.dragStartNode=this;
window.dhtmlDragAndDrop.dragStartObject=this.dragStarter;
document.body.onmouseup=window.dhtmlDragAndDrop.preCreateDragCopy;
document.body.onmousemove=window.dhtmlDragAndDrop.callDrag;
if ((e)&&(e.preventDefault)) { e.preventDefault(); return false; }
return false;
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -