If (null = Window. xtable) { Window. xtable = {}; Window. xtable. dragdrop = {}; Window. xtable. dragdrop. temprow = NULL; Window. xtable. dragdrop. isprocessing = false; Window. xtable. dragdrop. bgcolorinitrow = NULL; Window. xtable. dragdrop. bgcoloroverrow = NULL; Window. xtable. dragdrop. rowover = NULL; Window. xtable. dragdrop. divstyle = "color: White;" + "Background-color: # 6e7b8b;" + "Position: absolute;" + "Z-index: 9000;" + "Border: solid 2px # 68228b;" + "Width: 300px;" + "Padding: 2px ;"; Window. xtable. dragdrop. tdstyle = "color: #98fb98;" + "White-space: nowrap;" + "Border: solid 1px # 6c7b8b;" + "Padding-left: 5px;" + "Padding-Right: 3px ;"; Window. xtable. dragdrop. overcolor = "#708090 "; Window. xtable. dragdrop. maskcolor = "# cdba96 "; Window. xtable. rowdragdropmousedown = function (TR) { If (null = tr | tr. parentelement = NULL | tr. parentelement. tagname! = "Tbody ") { Return; } Window. xtable. dragdrop. bgcolorinitrow = tr. style. backgroundcolor; Tr. style. backgroundcolor = Window. xtable. dragdrop. maskcolor; If (null = Window. xtable. dragdrop. temprow) { Window. xtable. dragdrop. temprow = Document. createelement ("<Div style = '" + window. xtable. dragdrop. divstyle + "'> "); Document. Body. appendchild (window. xtable. dragdrop. temprow ); Window. xtable. dragdrop. temprow. appendchild (document. createtextnode ("drag to the top of the target row, and the row is automatically placed before the target row ")); } While (window. xtable. dragdrop. temprow. Children & window. xtable. dragdrop. temprow. Children. length> 1) { Window. xtable. dragdrop. temprow. removechild (window. xtable. dragdrop. temprow. Children [1]); } Window. xtable. dragdrop. temprow. style. Display = "Block "; Window. xtable. dragdrop. temprow. style. Top = event. clienty + scrolltop (); Window. xtable. dragdrop. temprow. style. Left = event. clientx + scrollleft () + 10; $ A (tr. Children). Each (function (TD, idx) { VaR NTD = Document. createelement ("<span style = '" + window. xtable. dragdrop. tdstyle + "'> "); NTD. appendchild (document. createtextnode (TD. innertext )); Window. xtable. dragdrop. temprow. appendchild (NTD) }); Window. xtable. dragdrop. isprocessing = true; Tr. setcapture (); } Window. xtable. rowdragdropmousemove = function (TR) { If (null! = Window. xtable. dragdrop. rowover) { Window. xtable. dragdrop. rowover. style. backgroundcolor = Window. xtable. dragdrop. bgcoloroverrow; Window. xtable. dragdrop. rowover = NULL; } If (false = Window. xtable. dragdrop. isprocessing) { Return false; } Window. xtable. dragdrop. temprow. style. Top = event. clienty + scrolltop (); Window. xtable. dragdrop. temprow. style. Left = event. clientx + scrollleft () + 10; VaR target = Document. elementfrompoint (event. X, event. y ); While (null! = Target & target. tagname! = "TR ") { Target = target. parentelement; } If (! Target | null = target. parentelement | target. parentelement. tagname! = "Tbody ") { Return; } Window. xtable. dragdrop. bgcoloroverrow = target. style. backgroundcolor; Window. xtable. dragdrop. rowover = target; Target. style. backgroundcolor = Window. xtable. dragdrop. overcolor; } Window. xtable. rowdragdropmouseup = function (TR) { Tr. releasecapture (); Tr. style. backgroundcolor = Window. xtable. dragdrop. bgcolorinitrow; If (null! = Window. xtable. dragdrop. rowover) { Window. xtable. dragdrop. rowover. style. backgroundcolor = Window. xtable. dragdrop. bgcoloroverrow; Window. xtable. dragdrop. rowover = NULL; } If (null! = Window. xtable. dragdrop. temprow) { Window. xtable. dragdrop. temprow. style. Display = "NONE "; } If (! Window. xtable. dragdrop. isprocessing) { Return false; } Window. xtable. dragdrop. isprocessing = false; VaR target = Document. elementfrompoint (event. X, event. y ); While (null! = Target & target. tagname! = "TR ") { Target = target. parentelement; } If (! Target | null = target. parentelement | target. parentelement. tagname! = "Tbody ") { Return; } Target. insertadjacentelement ("beforebegin", TR ); } Window. xtable. makedragdrop = function (tablename) { VaR table = $ (tablename ); If (null = table) { Return; } If (! Table. tbodies | table. tbodies. Length <1) { Return; } $ A (table. tbodies [0]. Rows). Each (function (TR, n) { (Function (TR) { Tr. onmousedown = function () { Window. xtable. rowdragdropmousedown (TR ); } Tr. onmousemove = function () { Window. xtable. rowdragdropmousemove (TR ); } Tr. onmouseup = function () { Window. xtable. rowdragdropmouseup (TR ); } } ) (TR ); }); } } |