📄 dhtml.js
字号:
if(this.pageHandler)this.pageHandler.__resetActivePageNumber();
}
,
resetServersideSortCurrentStartIndex:function()
{
this.serversideSortCurrentStartIndex = 0;
}
,
__updateSortArrow:function(obj,direction)
{
var images = obj.getElementsByTagName('IMG'); // Array of the images inside the clicked header cell(i.e. arrow up and down)
if(direction=='descending'){ // Setting visibility of arrow image based on sort(ascending or descending)
images[0].src = images[0].src.replace('arrow_up','arrow_down');
images[0].style.visibility='visible';
}else{
images[0].src = images[0].src.replace('arrow_down','arrow_up');
images[0].style.visibility='visible';
}
if(this.activeColumn && this.activeColumn!=obj){
var images = this.activeColumn.getElementsByTagName('IMG');
images[0].style.visibility='hidden';
this.activeColumn.removeAttribute('direction');
}
this.activeColumn = obj; // Setting this.activeColumn to the cell trigger this method
}
,
__getParsedCallbackString:function(functionName)
{
var objIndex = this.objectIndex;
if(!functionName)
functionName='true';
else
functionName = functionName + '(DHTMLSuite.variableStorage.arrayOfDhtmlSuiteObjects[' + objIndex + '])';
return functionName;
}
,
__getItemsFromServer:function(callbackFunctionNavigation)
{
callbackFunctionNavigation = this.__getParsedCallbackString(callbackFunctionNavigation);
var objIndex = this.objectIndex;
var url = this.serversideSortFileName + '?sortBy=' + this.tableCurrentlySortedBy + '&numberOfRows=' + this.serversideSortNumberOfRows + '&sortAscending=' + this.serversideSortAscending + '&startIndex=' + this.serversideSortCurrentStartIndex + this.serversideSortExtraSearchCriterias;
var index = DHTMLSuite.variableStorage.ajaxObjects.length;
try{
DHTMLSuite.variableStorage.ajaxObjects[index] = new sack();
}catch(e){ // Unable to create ajax object - send alert message and return from sort method.
alert('Unable to create ajax object. Please make sure that the sack js file is included on your page(js/ajax.js)');
return;
}
DHTMLSuite.variableStorage.ajaxObjects[index].requestFile = url; // Specifying which file to get
DHTMLSuite.variableStorage.ajaxObjects[index].onCompletion = function(){ DHTMLSuite.variableStorage.arrayOfDhtmlSuiteObjects[objIndex].__parseDataContentFromServer(index);eval(callbackFunctionNavigation) }; // Specify function that will be executed after file has been found
DHTMLSuite.variableStorage.ajaxObjects[index].runAJAX(); // Execute AJAX function
}
,
__sortTable:function(obj,howToSort)
{
if(this.serversideSort){
if(!this.serversideSortFileName){ // Server side file name defined.
alert('No server side file defined. Use the setServersideSortFileName to specify where to send the ajax request');
return;
}
var sortBy = obj.getAttribute('sortBy');
if(!sortBy)sortBy = obj.sortBy;
if(!sortBy){
alert('Sort is not defined. Remember to set a sortBy attribute on the header <td> tags');
return;
}
if(sortBy==this.tableCurrentlySortedBy)this.serversideSortAscending = !this.serversideSortAscending;else this.serversideSortAscending = true;
if(howToSort)this.serversideSortAscending = (howToSort=='ascending'?true:false);
this.tableCurrentlySortedBy = sortBy;
this.serversideSortCurrentStartIndex =0;
this.__getItemsFromServer();
if(this.pageHandler)this.pageHandler.__resetActivePageNumber();
this.__updateSortArrow(obj,this.serversideSortAscending?'ascending':'descending');
return;
}
if(!this.tableWidget_okToSort)return;
this.tableWidget_okToSort = false;
var indexThis = 0;
var tmpObj = obj;
while(tmpObj.previousSibling){
tmpObj = tmpObj.previousSibling;
if(tmpObj.tagName=='TD')indexThis++;
}
if(obj.getAttribute('direction') || obj.direction){ // Determine if we should sort ascending or descending
direction = obj.getAttribute('direction');
if(navigator.userAgent.indexOf('Opera')>=0)direction = obj.direction;
if(direction=='ascending' || howToSort=='descending'){
direction = 'descending';
obj.setAttribute('direction','descending');
obj.direction = 'descending';
}else{
direction = 'ascending';
obj.setAttribute('direction','ascending');
obj.direction = 'ascending';
}
}else{ // First call to the sort method
var curDir = 'ascending'; // How to sort the table
if(howToSort)curDir = howToSort; // Initial sort method sent as argument to this method, call it by this method.
direction = curDir;
obj.setAttribute('direction',curDir);
obj.direction = curDir;
}
this.__updateSortArrow(obj,direction);
var tableObj = obj.parentNode.parentNode.parentNode;
var tBody = tableObj.getElementsByTagName('TBODY')[0];
var widgetIndex = tableObj.id.replace(/[^\d]/g,'');
var sortMethod = this.columnSortArray[indexThis]; // N = numeric, S = String
var cellArray = new Array();
var cellObjArray = new Array();
for(var no=1;no<tableObj.rows.length;no++){
var content= tableObj.rows[no].cells[indexThis].innerHTML+'';
cellArray.push(content);
cellObjArray.push(tableObj.rows[no].cells[indexThis]);
}
if(sortMethod=='N'){
cellArray = cellArray.sort(this.__sortNumeric);
}else{
cellArray = cellArray.sort(this.__sortString);
}
if(direction=='descending'){
for(var no=cellArray.length;no>=0;no--){
for(var no2=0;no2<cellObjArray.length;no2++){
if(cellObjArray[no2].innerHTML == cellArray[no] && !cellObjArray[no2].getAttribute('allreadySorted')){
cellObjArray[no2].setAttribute('allreadySorted','1');
tBody.appendChild(cellObjArray[no2].parentNode);
}
}
}
}else{
for(var no=0;no<cellArray.length;no++){
for(var no2=0;no2<cellObjArray.length;no2++){
if(cellObjArray[no2].innerHTML == cellArray[no] && !cellObjArray[no2].getAttribute('allreadySorted')){
cellObjArray[no2].setAttribute('allreadySorted','1');
tBody.appendChild(cellObjArray[no2].parentNode);
}
}
}
}
for(var no2=0;no2<cellObjArray.length;no2++){
cellObjArray[no2].removeAttribute('allreadySorted');
}
this.tableWidget_okToSort = true;
}
,
__highlightTableRow:function()
{
if(navigator.userAgent.indexOf('Opera')>=0)return;
this.className='DHTMLSuite_tableWidget_dataRollOver';
if(document.all){ // I.E fix for "jumping" headings
var divObj = this.parentNode.parentNode.parentNode;
var tHead = divObj.getElementsByTagName('TR')[0];
tHead.style.top = divObj.scrollTop + 'px';
}
}
,
__removeHighlightEffectFromTableRow:function()
{
if(navigator.userAgent.indexOf('Opera')>=0)return;
this.className=null;
if(document.all){ // I.E fix for "jumping" headings
var divObj = this.parentNode.parentNode.parentNode;
var tHead = divObj.getElementsByTagName('TR')[0];
tHead.style.top = divObj.scrollTop + 'px';
}
}
}
var DHTMLSuite_dragDropSimple_curZIndex = 100000;
var DHTMLSuite_dragDropSimple_curObjIndex=false;
DHTMLSuite.dragDropSimple = function(elementRef,elementId,initOffsetX,initOffsetY,cloneNode)
{
var divElement;
var dragTimer; // -1 no drag, 0-4 = initializing , 5 = drag in process
var cloneNode;
this.cloneNode = true;
if(cloneNode===false || cloneNode)this.cloneNode=cloneNode;
var callbackOnAfterDrag;
var callbackOnBeforeDrag;
var mouse_x;
var mouse_y;
var positionSet;
var dragHandle; // If a specific element is specified to be a drag handle.
this.positionSet = false;
this.dragHandle = new Array();
var initOffsetX;
var initOffsetY;
if(!initOffsetX)initOffsetX = 0;
if(!initOffsetY)initOffsetY = 0;
this.initOffsetX = initOffsetX;
this.initOffsetY = initOffsetY;
this.callbackOnAfterDrag = false;
this.callbackOnBeforeDrag = false;
this.dragStatus = -1;
try{
if(!standardObjectsCreated)DHTMLSuite.createStandardObjects(); // This line starts all the init methods
}catch(e){
alert('You need to include the dhtmlSuite-common.js file');
}
if(!elementRef && elementId)elementRef = document.getElementById(elementId);
this.divElement = elementRef;
var objectIndex;
this.objectIndex = DHTMLSuite.variableStorage.arrayOfDhtmlSuiteObjects.length;
DHTMLSuite.variableStorage.arrayOfDhtmlSuiteObjects[this.objectIndex] = this;
this.__init();
}
DHTMLSuite.dragDropSimple.prototype = {
__init:function()
{
var ind = this.objectIndex;
this.divElement.objectIndex = ind;
this.divElement.setAttribute('objectIndex',ind);
this.divElement.style.padding = '0px';
this.divElement.style.left = (DHTMLSuite.commonObj.getLeftPos(this.divElement) + this.initOffsetX) + 'px';
this.divElement.style.top = (DHTMLSuite.commonObj.getTopPos(this.divElement) + this.initOffsetY) + 'px';
this.divElement.style.position = 'absolute';
this.divElement.style.margin = '0px';
if(this.divElement.style.zIndex && this.divElement.style.zIndex/1>DHTMLSuite_dragDropSimple_curZIndex)DHTMLSuite_dragDropSimple_curZIndex=this.divElement.style.zIndex/1;
DHTMLSuite_dragDropSimple_curZIndex = DHTMLSuite_dragDropSimple_curZIndex/1 + 1;
this.divElement.style.zIndex = DHTMLSuite_dragDropSimple_curZIndex;
if(this.cloneNode){
var copy = this.divElement.cloneNode(true);
this.divElement.parentNode.insertBefore(copy,this.divElement);
copy.style.visibility = 'hidden';
document.body.appendChild(this.divElement);
}
this.divElement.onmousedown = this.__initDragProcess;
DHTMLSuite.commonObj.addEvent(document.documentElement,'mousemove',function(e){ DHTMLSuite.variableStorage.arrayOfDhtmlSuiteObjects[ind].__moveDragableElement(e); });
DHTMLSuite.commonObj.addEvent(document.documentElement,'mouseup',function(e){ DHTMLSuite.variableStorage.arrayOfDhtmlSuiteObjects[ind].__stopDragProcess(e); });
if(!document.documentElement.onselectstart)document.documentElement.onselectstart = function() { return DHTMLSuite.commonObj.__getOkToMakeTextSelections(); };
}
,
setCallbackOnAfterDrag:function(functionName)
{
this.callbackOnAfterDrag = functionName;
}
,
setCallbackOnBeforeDrag:function(functionName)
{
this.callbackOnBeforeDrag = functionName;
}
,
addDragHandle:function(dragHandle)
{
this.dragHandle[this.dragHandle.length] = dragHandle;
}
,
__initDragProcess:function(e)
{
if(document.all)e = event;
var ind = this.getAttribute('objectIndex');
if(!ind)ind=this.objectIndex;
DHTMLSuite_dragDropSimple_curObjIndex = ind;
var thisObject = DHTMLSuite.variableStorage.arrayOfDhtmlSuiteObjects[ind];
if(!DHTMLSuite.commonObj.isObjectClicked(thisObject.divElement,e))return;
if(thisObject.divElement.style.zIndex && thisObject.divElement.style.zIndex/1>DHTMLSuite_dragDropSimple_curZIndex)DHTMLSuite_dragDropSimple_curZIndex=thisObject.divElement.style.zIndex/1;
DHTMLSuite_dragDropSimple_curZIndex = DHTMLSuite_dragDropSimple_curZIndex/1 +1;
thisObject.divElement.style.zIndex = DHTMLSuite_dragDropSimple_curZIndex;
if(thisObject.callbackOnBeforeDrag){
thisObject.__handleCallback('beforeDrag');
}
if(thisObject.dragHandle.length>0){ // Drag handle specified?
var objectFound;
for(var no=0;no<thisObject.dragHandle.length;no++){
if(!objectFound)objectFound = DHTMLSuite.commonObj.isObjectClicked(thisObject.dragHandle[no],e);
}
if(!objectFound)return;
}
DHTMLSuite.commonObj.__setOkToMakeTextSelections(false);
thisObject.mouse_x = e.clientX;
thisObject.mouse_y = e.clientY;
thisObject.el_x = thisObject.divElement.style.left.replace('px','')/1;
thisObject.el_y = thisObject.divElement.style.top.replace('px','')/1;
thisObject.dragTimer = 0;
thisObject.__waitBeforeDragProcessStarts();
return false;
}
,
__waitBeforeDragProcessStarts:function()
{
var ind = this.objectIndex;
if(this.dragTimer>=0 && this.dragTimer<5){
this.dragTimer++;
setTimeout('DHTMLSuite.variableStorage.arrayOfDhtmlSuiteObjects[' + ind + '].__waitBeforeDragProcessStarts()',5);
}
}
,
__moveDragableElement:function(e)
{
if(DHTMLSuite_dragDropSimple_curObjIndex===false)return false;
var thisObj = DHTMLSuite.variableStorage.arrayOfDhtmlSuiteObjects[DHTMLSuite_dragDropSimple_curObjIndex];
if(thisObj.dragTimer==5){
thisObj.divElement.style.left = (e.clientX - thisObj.mouse_x + thisObj.el_x) + 'px';
thisObj.divElement.style.top = (e.clientY - thisObj.mouse_y + thisObj.el_y) + 'px';
}
return false;
}
,
__stopDragProcess:function()
{
if(DHTMLSuite_dragDropSimple_curObjIndex===false)return;
DHTMLSuite.commonObj.__setOkToMakeTextSelections(true);
var thisObj = DHTMLSuite.variableStorage.arrayOfDhtmlSuiteObjects[DHTMLSuite_dragDropSimple_curObjIndex];
if(thisObj.dragTimer==5){
thisObj.__handleCallback('afterDrag');
}
thisObj.dragTimer = -1;
}
,
__handleCallback:function(action)
{
var callbackString = '';
switch(action){
case "afterDrag":
callbackString = this.callbackOnAfterDrag;
break;
case "beforeDrag":
callbackString = this.callbackOnBeforeDrag;
break;
}
if(callbackString){
callbackString = callbackString + '()';
try{
eval(callbackString);
}catch(e){
alert('Could not execute callback function(' + callbackstring + ') after drag');
}
}
}
,
__setNewCurrentZIndex:function(zIndex)
{
if(zIndex > DHTMLSuite_dragDropSimple_curZIndex){
DHTMLSuite_dragDropSimple_curZIndex = zIndex/1+1;
}
}
}
DHTMLSuite.dragDrop = function()
{
var mouse_x; // mouse x position when drag is started
var mouse_y; // mouse y position when drag is started.
var el_x; // x position of dragable element
var el_y; // y position of dragable element
var dragDropTimer; // Timer - short delay from mouse down to drag init.
var numericIdToBeDragged; // numeric reference to element currently being dragged.
var dragObjCloneArray; // Array of cloned dragable elements. every
var dragDropSourcesArray; // Array of source elements, i.e. dragable elements.
var dragDropTargetArray; // Array of target elements, i.e. elements where items could be dropped.
var currentZIndex; // Current z index. incremented on each drag so that currently dragged element is always on top.
var okToStartDrag; // Variable which is true or false. It would be false for 1/100 seconds after a drag has been started.
var moveBackBySliding; // Variable indicating if objects should slide into place moved back to their location without any slide animation.
var dragX_allowed; // Possible to drag this element along the x-axis?
var dragY_allowed; // Possible to drag this element along the y-axis?
var currentEl_allowX;
var currentEl_allowY;
var drag_minX;
var drag_maxX;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -