ns-components-angular
Version:
Angular Wrapper Components for NSComponents
2 lines (1 loc) • 29.2 kB
TypeScript
export declare const NSTableRowMoverCode = "var nsModuleExport = function(root,name,prototype)\r\n\t{\r\n\t\tif(typeof exports === 'object' && typeof module === 'object')\r\n\t\t{\r\n\t\t\tmodule.exports[name] = prototype;\r\n\t\t}\r\n\t\telse if (typeof define === \"function\" && define.amd)\r\n\t\t{\r\n\t\t\tdefine(name,[], function () {return prototype;});\r\n\t\t}\r\n\t\telse if(typeof exports === 'object')\r\n\t\t{\r\n\t\t\texports[name] = prototype;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\troot[name] = prototype;\r\n\t\t}\r\n\t};var nsIsWeb = function(root)\r\n\t{\r\n\t\tif(typeof exports === 'object' && typeof module === 'object')\r\n\t\t{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\telse if (typeof define === \"function\" && define.amd)\r\n\t\t{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\telse if(typeof exports === 'object')\r\n\t\t{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\treturn true;\r\n\t\t}\r\n\t};if(!nsIsWeb())\r\n\t\t{\r\nvar nsutilRef = require('./nsUtil.min.js');\r\nvar NSUtil = nsutilRef.NSUtil;\r\nvar nscontainerbaseRef = require('./nsContainerBase.min.js');\r\nvar nsExtendPrototype = nscontainerbaseRef.nsExtendPrototype;\r\nvar NSContainerBase = nscontainerbaseRef.NSContainerBase;\r\nvar svgRef = require('./nsSVG.min.js');\r\nvar NSSvg = svgRef.NSSvg;\r\nvar NSSvgShapes = svgRef.NSSvgShapes;\r\nvar plugginsRef = require('./nsPluggins.min.js');\r\nvar nsTextEditor = plugginsRef.nsTextEditor;\r\nvar nsTextAreaEditor = plugginsRef.nsTextAreaEditor;\r\nvar NSCellSelection = plugginsRef.NSCellSelection;\r\nvar NSTableCellNavigator = plugginsRef.NSTableCellNavigator;\r\nvar dateutilRef = require('./nsDateUtil.min.js');\r\nvar NSDateUtil = dateutilRef.NSDateUtil;\r\n\r\n\t\t}\r\n\"use strict\";\r\nvar NSTableRowMover = (function()\r\n{\r\n\tfunction NSTableRowMover(setting) \r\n\t{\r\n\t\tthis.util = new NSUtil();\r\n\t\t\r\n\t\tthis.__id = null;\r\n\t\tthis.__setting = setting;\r\n\t\tthis.__config = null;\r\n\t\t\r\n\t\tthis.__currentRow = null;\r\n\t\tthis.__targetRow = null;\r\n\t\tthis.__rowMouseOffset = null;\r\n\t\tthis.__lastYPos = 0;\r\n\t\tthis.__oldIndex = -1;\r\n\t\tthis.__touchSupport = false;\r\n\t\tthis.__touchID = null;\r\n\t\tthis.__divGhost = null;\r\n\t\tthis.__verticalOffset = 0;\r\n\t\tthis.__rowIndex = 0;\r\n\t\tthis.__mapRowIndex = {};\r\n\t\t\r\n\t\tthis.__divMovable = null;\r\n\t\tthis.__lastVisitedRow = null;\r\n\t\t\r\n\t\tthis.__mouseMoveRef = null;\r\n\t\tthis.__documentMouseUpRef = null;\r\n\t\t\r\n\t\tthis.__initialize();\r\n\t}\r\n\t\r\n\tNSTableRowMover.prototype.remove = function() \r\n\t{ \r\n\t\tthis.__removeDocumentEvents();\r\n\t};\r\n\t\r\n\tNSTableRowMover.prototype.processRows = function() \r\n\t{ \r\n\t\tthis.__processRows();\r\n\t};\r\n\t\r\n\tNSTableRowMover.prototype.__initialize = function()\r\n\t{\r\n\t\tif(this.__setting)\r\n\t\t{\r\n\t\t\tthis.__config = {\r\n\t\t\t\t\ttable: this.__setting[\"table\"] || null,\r\n\t\t\t\t\tisSameTableMove: (this.util.isUndefined(this.__setting[\"isSameTableMove\"]) || this.__setting[\"isSameTableMove\"] === null) ? true : Boolean.parse(this.__setting[\"isSameTableMove\"]),\r\n\t\t\t\t\tdroppableTable: this.__setting[\"droppableTable\"] || null,\r\n\t\t\t\t\thandler: this.__setting[\"handler\"] || null,\r\n\t\t\t\t\tdragStartHandler: (this.__setting[\"dragStartHandler\"] ? this.util.getFunction(this.__setting[\"dragStartHandler\"]) : null),\r\n\t\t\t\t\tdragHandler: (this.__setting[\"dropHandler\"] ? this.util.getFunction(this.__setting[\"dropHandler\"]) : null),\r\n\t\t\t\t\tdragEndHandler: (this.__setting[\"dragEndHandler\"] ? this.util.getFunction(this.__setting[\"dragEndHandler\"]) : null),\r\n\t\t\t\t\tcustomClass: this.__setting[\"customClass\"] || {table: null,dragRow: null},\r\n\t\t\t\t\tenableAnimation: Boolean.parse(this.__setting[\"enableAnimation\"]),\r\n\t\t\t\t\tenableMovingText: Boolean.parse(this.__setting[\"enableMovingText\"]),\r\n\t\t\t\t\tmovingTextCallback: (this.__setting[\"movingTextCallback\"] ? this.util.getFunction(this.__setting[\"movingTextCallback\"]) : null),\r\n\t\t\t};\r\n\t\t\tif(this.__config.table)\r\n\t\t\t{\r\n\t\t\t\tthis.__processTableForAnimation();\r\n\t\t\t\tthis.__touchSupport = !!(\"ontouchstart\" in document);\r\n\t\t\t\tthis.__processRows();\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSTableRowMover.prototype.__processRows = function() \r\n\t{\r\n\t\tif(this.__config.enableAnimation)\r\n\t\t{\r\n\t\t\tthis.__verticalOffset = 0;\r\n\t\t\tthis.__rowIndex = 0;\r\n\t\t}\r\n\t\tif(this.__config.table.tHead && this.__config.table.tHead.rows)\r\n\t\t{\r\n\t\t\tvar rows = this.__config.table.tHead.rows;\r\n\t\t\tfor (var count = 0; count < rows.length; count++) \r\n\t {\r\n\t \tvar row = rows[count];\r\n\t \trow.setAttribute(\"nsDropAllowed\",false);\r\n\t \tthis.__makeRowAbsolute(row);\r\n\t }\r\n\t\t}\r\n\t\tvar rows = this.__config.table.tBodies[0].rows;\r\n for (var count = 0; count < rows.length; count++) \r\n {\r\n \tvar row = rows[count];\r\n \tvar dragAllowed = true;\r\n \t\tif(this.util.hasAttribute(row,\"nsDragAllowed\"))\r\n \t\t{\r\n \t\t\tdragAllowed = Boolean.parse(this.util.getAttribute(row,\"nsDragAllowed\"));\r\n \t\t}\r\n\t\t\tif (dragAllowed) \r\n\t\t\t{ \r\n\t\t\t\tthis.__makeRowDraggable(row);\r\n\t\t\t}\r\n }\r\n\t};\r\n\t\r\n\tNSTableRowMover.prototype.__processTableForAnimation = function() \r\n\t{\r\n\t\tif(this.__config.enableAnimation)\r\n\t\t{\r\n\t\t\tthis.__config.table.style.position = \"relative\";\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSTableRowMover.prototype.__rowMouseDownHandler= function(event)\r\n\t{\r\n\t\tevent = this.util.getEvent(event);\r\n\t var target = this.util.getTarget(event);\r\n\t target = this.util.findParent(target,\"TR\");\r\n\t var offset = this.util.getMouseOffset(event,target);\r\n\t var posEvent = this.util.getEventPosition(event);\r\n this.__mouseStartEvent = event;\r\n\t if(this.__dragStart(target,offset,posEvent))\r\n\t {\r\n\t \tevent.preventDefault();\r\n\t }\r\n\t};\r\n\t\r\n\tNSTableRowMover.prototype.__rowTouchStartHandler= function(event)\r\n\t{\r\n\t\tif(event.touches.length === 1) \r\n\t\t{\r\n\t\t\tvar touch = event.touches[0];\r\n\t this.__touchStart = touch;\r\n\t\t\tthis.__touchID = touch.identifier;\r\n target = document.elementFromPoint(touch.clientX, touch.clientY);\r\n\t\t target = this.util.findParent(target,\"TR\");\r\n\t\t var offset = this.util.getMouseOffset(touch,target);\r\n\t\t var posEvent = this.util.getEventPosition(touch);\r\n\t\t if(this.__dragStart(target,offset,posEvent))\r\n\t\t {\r\n\t\t \t if(event.preventDefault) \r\n\t\t \t {\r\n\t\t \t\t event.preventDefault();\r\n\t } \r\n\t\t \t else \r\n\t\t \t {\r\n\t\t \t\t event.returnValue = false;\r\n\t }\r\n\t\t \t return false;\r\n\t\t }\r\n\t\t}\r\n\t\t return true;\r\n\t};\r\n\t\r\n\tNSTableRowMover.prototype.__mouseMoveHandler = function(event)\r\n\t{\r\n\t\tif(this.__currentRow)\r\n\t\t{\r\n\t\t\tevent = this.util.getEvent(event);\r\n\t\t\tvar mousePosition = this.util.getEventPosition(event);\r\n\t\t\tvar target = this.util.getTarget(event);\r\n\t\t\tvar posEvent = this.util.getEventPosition(event);\r\n\t\t\tif(this.__dragging(target,mousePosition,posEvent,event,this.__mouseStartEvent))\r\n\t\t\t{\r\n\t\t\t\t event.preventDefault();\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSTableRowMover.prototype.__touchMoveHandler = function(event)\r\n\t{\r\n\t\tif(event.touches.length === 1 && this.__currentRow) \r\n\t\t{\r\n\t\t\tvar touch = event.touches[0];\r\n var target = document.elementFromPoint(touch.clientX, touch.clientY);\r\n var position = this.util.getEventPosition(touch);\r\n \t\t var posEvent = this.util.getEventPosition(touch);\r\n \t\t if(this.__dragging(target,position,posEvent,touch,this.__touchStart))\r\n\t\t\t{\r\n \t\t \t if(event.preventDefault) \r\n\t\t \t {\r\n\t\t \t\t event.preventDefault();\r\n\t } \r\n\t\t \t else \r\n\t\t \t {\r\n\t\t \t\t event.returnValue = false;\r\n\t }\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSTableRowMover.prototype.__documentMouseUpHandler = function(event)\r\n\t{\r\n\t\tif(this.__currentRow) \r\n\t {\r\n\t\t\tevent = this.util.getEvent(event);\r\n\t\t\tvar mousePosition = this.util.getEventPosition(event);\r\n\t\t\tthis.__dragEnd(mousePosition);\r\n\t }\r\n\t};\r\n\t\r\n\tNSTableRowMover.prototype.__documentTouchUpHandler = function(event)\r\n\t{\r\n\t\tif(event.touches.length === 1 && this.__currentRow) \r\n\t\t{\r\n\t\t\tvar touch = event.touches[0];\r\n var position = this.util.getEventPosition(touch);\r\n this.__dragEnd(position);\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSTableRowMover.prototype.__dragStart = function(target,offset,posEvent) \r\n\t{\r\n\t\tthis.__currentRow = target;\r\n\t this.__rowMouseOffset = offset;\r\n\t this.util.makeBodyUnselectable();\r\n\t if(this.__currentRow)\r\n\t {\r\n\t \tthis.__oldIndex = this.__currentRow.rowIndex;\r\n\t \tif(this.__config.dragStartHandler)\r\n {\r\n \tthis.__config.dragStartHandler(this.__currentRow,{targetTable: this.__config.table,targetRow: this.__currentRow,oldIndex:this.__oldIndex});\r\n }\r\n\t \tthis.__applyCustomClass(this.__config.table,\"table\",null);\r\n\t \tthis.__applyCustomClass(this.__currentRow,\"dragRow\",\"nsDraggingRow\");\r\n\t\t\tif(!this.__config.isSameTableMove)\r\n\t\t\t{\r\n\t\t\t\tthis.__divMovable = this.util.createDiv(this.__getID() + \"clonedRow\", \"nsDraggableCloneRow\");\r\n\t\t\t\tvar table = document.createElement(\"table\");\r\n\t\t\t\tvar body = document.createElement(\"tbody\");\r\n\t\t\t\tvar row = this.__currentRow.cloneNode(true);\r\n\t\t\t\tbody.appendChild(row);\r\n\t\t\t\ttable.appendChild(body);\r\n\t\t\t\tthis.__divMovable.appendChild(table);\r\n\t\t\t\tdocument.body.appendChild(this.__divMovable);\r\n\t\t\t\tthis.__setDivMovablePosition(posEvent);\r\n\t\t\t}\r\n\t\t\tthis.__addDocumentEvents();\r\n\t\t\tthis.__createGhost(this.__currentRow);\r\n\t\t\treturn true;\r\n\t }\r\n\t return false;\r\n\t};\r\n\t\r\n\tNSTableRowMover.prototype.__dragging = function(target,position,posEvent,event,startEvent) \r\n\t{\r\n\t\tif(this.__currentRow)\r\n\t\t{\r\n\t\t\tvar yPos = position.top - this.__rowMouseOffset.y;\r\n\t if(yPos != this.__lastYPos) \r\n\t {\r\n\t var movingDown = yPos > this.__lastYPos;\r\n\t this.__lastYPos = yPos;\r\n\t if(this.__config.isSameTableMove) \r\n\t {\r\n\t \tthis.__targetRow = this.util.findParent(target,\"TR\");\r\n\t \tvar isAppendChild = false;\r\n\t \tvar moveRow = null;\r\n\t\t if(this.__targetRow && this.__currentRow != this.__targetRow) \r\n\t\t {\r\n\t\t \tthis.__positionGhost(event);\r\n\t\t \tmoveRow = this.__targetRow;\r\n\t\t \tif(this.__config.enableAnimation)\r\n\t \t{\r\n\t\t \tif(this.__isRowDropable(moveRow,this.__currentRow))\r\n\t\t \t{\r\n\t\t\t\t \tvar currentProp = this.__currentRow.getAttribute(\"data-rowMover-id\");\r\n\t\t\t\t \tvar targetProp = this.__targetRow.getAttribute(\"data-rowMover-id\");\r\n\t\t\t\t var currentValue = this.__mapRowIndex[currentProp].top;\r\n\t\t\t\t var targetValue = this.__mapRowIndex[targetProp].top;\r\n\t\t\t\t this.__currentRow.style.transform = \"translateY(\" + targetValue + \"px)\";\r\n\t\t\t\t this.__targetRow.style.transform = \"translateY(\" + currentValue + \"px)\";\r\n\t\t\t\t this.__mapRowIndex[currentProp].top = targetValue;\r\n\t\t\t\t this.__mapRowIndex[targetProp].top = currentValue;\r\n\t\t \t}\r\n\t \t}\r\n\t\t \telse\r\n\t\t \t{\r\n\t\t\t if (movingDown) \r\n\t\t\t {\r\n\t\t\t \tif(this.__targetRow.nextSibling)\r\n\t\t\t \t{\r\n\t\t\t \t\tmoveRow = this.__targetRow.nextSibling;\r\n\t\t\t \t}\r\n\t\t\t \telse\r\n\t\t\t \t{\r\n\t\t\t \t\tmoveRow = this.__currentRow;\r\n\t\t\t \t\tisAppendChild = true;\r\n\t\t\t \t}\r\n\t\t\t } \r\n\t\t\t else if (!movingDown) \r\n\t\t\t {\r\n\t\t\t \tmoveRow = this.__targetRow;\r\n\t\t\t }\r\n\t\t\t if(moveRow)\r\n\t\t\t {\r\n\t\t\t \tif(this.__isRowDropable(moveRow,this.__currentRow))\r\n\t\t\t \t{\r\n\t\t\t\t \tif(this.__config.enableAnimation)\r\n\t\t\t\t \t{\r\n\t\t\t\t\t\t \tvar currentProp = this.__currentRow.getAttribute(\"data-rowMover-id\");\r\n\t\t\t\t\t\t \tvar targetProp = this.__targetRow.getAttribute(\"data-rowMover-id\");\r\n\t\t\t\t\t\t var currentValue = this.__mapRowIndex[currentProp].top;\r\n\t\t\t\t\t\t var targetValue = this.__mapRowIndex[targetProp].top;\r\n\t\t\t\t\t\t this.__currentRow.style.transform = \"translateY(\" + targetValue + \"px)\";\r\n\t\t\t\t\t\t this.__targetRow.style.transform = \"translateY(\" + currentValue + \"px)\";\r\n\t\t\t\t\t\t this.__mapRowIndex[currentProp].top = targetValue;\r\n\t\t\t\t\t\t this.__mapRowIndex[targetProp].top = currentValue;\r\n\t\t\t\t \t}\r\n\t\t\t\t \telse\r\n\t\t\t\t \t{\r\n\t\t\t\t \t\tvar parent = this.__targetRow.parentNode;\r\n\t\t\t\t \t\tif(isAppendChild)\r\n\t\t\t\t \t\t{\r\n\t\t\t\t \t\t\tparent.appendChild(moveRow);\r\n\t\t\t\t \t\t}\r\n\t\t\t\t \t\telse\r\n\t\t\t\t \t\t{\r\n\t\t\t\t \t\t\tparent.insertBefore(this.__currentRow,moveRow);\r\n\t\t\t\t \t\t}\r\n\t\t\t\t\t }\r\n\t\t\t\t }\r\n\t\t\t }\r\n\t\t \t}\r\n\t\t \tif(moveRow && this.__config.dragHandler)\r\n\t \t {\r\n\t \t \tthis.__config.dragHandler(this.__currentRow,{targetTable: this.__config.table,targetRow: moveRow,oldIndex:this.__oldIndex,newIndex:moveRow.rowIndex});\r\n\t \t }\r\n\t\t }\r\n\t }\r\n\t else if(this.__divMovable)\r\n\t {\r\n\t \tif(this.__lastVisitedRow)\r\n\t \t{\r\n\t \t\tthis.util.removeStyleClass(this.__lastVisitedRow,\"nsDottedRow\");\r\n\t \t\tthis.__lastVisitedRow = null;\r\n\t \t}\r\n\t \tthis.__setDivMovablePosition(posEvent);\r\n\t \tthis.__divMovable.style.display = \"none\";\r\n\t \t\tvar target = document.elementFromPoint(position.left,position.top);\r\n\t \t\t//for Opera\r\n\t \t\tif (target.nodeType === 3) \r\n\t \t\t{ \r\n\t \t\t\ttarget = target.parentNode;\r\n\t \t\t}\r\n\t \t\tvar targetTable = this.util.findChild(target,\"TABLE\");\r\n\t \t\tif(!targetTable)\r\n\t \t\t{\r\n\t \t\t\ttargetTable = this.util.findParent(target,\"TABLE\");\r\n\t \t\t}\r\n\t \t\tif(targetTable && targetTable.id != this.__config.table.id)\r\n\t \t\t{\r\n\t \t\t\tvar targetRow = this.__findDroppableRow(targetTable,mousePosition.top);\r\n\t \t\t\tif(targetRow)\r\n\t \t\t\t{\r\n\t \t\t\t\tif(this.__config.dragHandler)\r\n\t\t \t {\r\n\t\t \t \tthis.__config.dragHandler(this.__currentRow,{targetTable: targetTable,targetRow: targetRow,oldIndex:this.__oldIndex,newIndex:targetRow.rowIndex});\r\n\t\t \t }\r\n\t\t \t\tthis.util.addStyleClass(targetRow,\"nsDottedRow\");\r\n\t\t \t\tthis.__lastVisitedRow = targetRow;\r\n\t \t\t\t}\r\n\t \t\t}\r\n\t \t\tthis.__divMovable.style.display = \"\";\r\n\t }\r\n\t return true;\r\n\t }\r\n\t\t}\r\n\t\treturn false;\r\n\t};\r\n\t\r\n\tNSTableRowMover.prototype.__dragEnd = function(position) \r\n\t{\r\n\t\tthis.__removeDocumentEvents();\r\n\t if(this.__currentRow) \r\n\t {\r\n\t \tvar droppedRow = this.__currentRow;\r\n\t \tthis.__removeCustomClass(this.__config.table,\"table\",null);\r\n\t \tthis.__removeCustomClass(this.__currentRow,\"dragRow\",\"nsDraggingRow\");\r\n\t \tif(this.__config.isSameTableMove)\r\n\t \t{\r\n\t if(this.__config.dragEndHandler)\r\n\t {\r\n\t \tthis.__config.dragEndHandler(this.__currentRow,{targetTable: this.__config.table,targetRow: this.__targetRow,oldIndex:this.__oldIndex,newIndex:this.__currentRow.rowIndex});\r\n\t }\r\n\t \t}\r\n\t \telse if(this.__divMovable)\r\n\t {\r\n\t \t\tthis.__divMovable.style.display = \"none\";\r\n\t \t\tvar target = document.elementFromPoint(position.left,position.top);\r\n\t \t\t//for Opera\r\n\t \t\tif (target.nodeType === 3) \r\n\t \t\t{ \r\n\t \t\t\ttarget = target.parentNode;\r\n\t \t\t}\r\n\t \t\tvar targetTable = this.util.findChild(target,\"TABLE\");\r\n\t \t\tif(!targetTable)\r\n\t \t\t{\r\n\t \t\t\ttargetTable = this.util.findParent(target,\"TABLE\");\r\n\t \t\t}\r\n\t \t\tvar targetRow = this.__findDroppableRow(targetTable,position.top);\r\n\t \t\tif(this.__lastVisitedRow)\r\n\t \t{\r\n\t \t\tthis.util.removeStyleClass(this.__lastVisitedRow,\"nsDottedRow\");\r\n\t \t\tthis.__lastVisitedRow = null;\r\n\t \t}\r\n\t \t\tthis.__divMovable.parentNode.removeChild(this.__divMovable);\r\n\t \t\tthis.__divMovable = null;\r\n\t \t\tif(this.__config.dragEndHandler)\r\n\t {\r\n\t \tthis.__config.dragEndHandler(this.__currentRow,{targetTable: targetTable,targetRow: targetRow,oldIndex:this.__oldIndex,newIndex:this.__currentRow.rowIndex});\r\n\t }\r\n\t \t}\r\n\t this.__currentRow = null;\r\n\t this.__oldIndex = -1;\r\n\t this.__removeGhost();\r\n\t this.util.makeBodySelectable();\r\n\t return true;\r\n\t }\r\n\t return false;\r\n\t};\r\n\t\r\n\tNSTableRowMover.prototype.__getComputedTranslateXY = function(obj)\r\n\t{\r\n\t\tconst transArr = [];\r\n\t if(!window.getComputedStyle) return;\r\n\t const style = window.getComputedStyle(obj),\r\n\t transform = style.transform || style.webkitTransform || style.mozTransform;\r\n\t let mat = transform.match(/^matrix3d\\((.+)\\)$/); \r\n\t if(mat) return parseFloat(mat[1].split(', ')[13]);\r\n\t mat = transform.match(/^matrix\\((.+)\\)$/);\r\n\t mat ? transArr.push(parseFloat(mat[1].split(', ')[4])) : 0;\r\n\t mat ? transArr.push(parseFloat(mat[1].split(', ')[5])) : 0;\r\n\t console.log(transArr);\r\n\t return transArr;\r\n\t};\r\n\t\r\n\tNSTableRowMover.prototype.__makeRowDraggable = function(row) \r\n\t{\r\n\t if(row)\r\n\t {\r\n\t \tthis.__makeRowAbsolute(row);\r\n\t \tif(!this.util.hasStyleClass(row,\"nsDraggableRow\"))\r\n\t \t{\r\n\t \t\tthis.util.addStyleClass(row,\"nsDraggableRow\");\r\n\t \t\tif(this.__config.handler)\r\n\t\t \t{\r\n\t\t \t\tvar handler = row.querySelector(this.__config.handler);\r\n\t\t \t\tif(handler)\r\n\t\t \t\t{\r\n\t\t \t\t\tif(this.__touchSupport)\r\n\t\t\t\t \t{\r\n\t\t\t\t \t\tthis.util.addEvent(handler,\"touchstart\",this.__rowTouchStartHandler.bind(this));\r\n\t\t\t\t \t}\r\n\t\t\t\t \telse\r\n\t\t\t\t \t{\r\n\t\t\t\t \t\tthis.util.addEvent(handler,\"mousedown\",this.__rowMouseDownHandler.bind(this));\r\n\t\t\t\t \t}\r\n\t\t \t\t}\r\n\t\t \t}\r\n\t\t \telse\r\n\t\t \t{\r\n\t\t \t\tthis.util.addStyleClass(row,\"nsDraggableRowDrag\");\r\n\t\t \t\tif(this.__touchSupport)\r\n\t\t\t \t{\r\n\t\t\t \t\tthis.util.addEvent(row,\"touchstart\",this.__rowTouchStartHandler.bind(this));\r\n\t\t\t \t}\r\n\t\t\t \telse\r\n\t\t\t \t{\r\n\t\t\t \t\tthis.util.addEvent(row,\"mousedown\",this.__rowMouseDownHandler.bind(this));\r\n\t\t\t \t}\r\n\t\t \t}\r\n\t \t}\r\n\t }\r\n\t};\r\n\t\r\n\tNSTableRowMover.prototype.__makeRowAbsolute = function(row) \r\n\t{\r\n\t\tvar rect = row.getBoundingClientRect();\r\n console.log(row.clientHeight + \" == \" + rect.height);\r\n\t\tif(this.__config.enableAnimation)\r\n\t\t{\r\n\t\t\tvar rowID = \"row-\" + (this.__rowIndex++);\r\n\t\t\tthis.util.addStyleClass(row,\"nsTableRowMoverAnimation\");\r\n\t\t\trow.setAttribute(\"data-rowMover-id\",rowID);\r\n\t\t\trow.style.transform = \"translateY(\" + this.__verticalOffset + \"px)\";\r\n\t\t\tthis.__mapRowIndex[rowID] = {top: this.__verticalOffset};\r\n\t\t\tthis.__verticalOffset += this.util.getOuterHeight(row);\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSTableRowMover.prototype.__isRowDropable = function(row,movingRow) \r\n\t{\r\n\t\tvar retValue = false;\r\n\t\tif(row && this.util.isElement(row) && this.util.isElementOfType(row,\"TR\"))\r\n\t\t{\r\n\t\t\tretValue = true;\r\n\t\t\tif(this.util.hasAttribute(row,\"nsDropAllowed\"))\r\n\t\t\t{\r\n\t\t\t\tretValue = Boolean.parse(this.util.getAttribute(row,\"nsDropAllowed\"));\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn retValue;\r\n\t};\r\n\t\r\n\tNSTableRowMover.prototype.__findDroppableRow = function(table,yPos) \r\n\t{\r\n\t\tif(table && table.tBodies && table.tBodies.length > 0)\r\n\t\t{\r\n\t\t\tvar rows = table.tBodies[0].rows;\r\n\t\t\tfor (var count = 0; count < rows.length; count++) \r\n\t\t\t{\r\n\t\t\t\tvar row = rows[count];\r\n\t\t\t\tvar dropAllowed = true;\r\n\t\t\t\tif(row.getAttribute(\"nsDropAllowed\"))\r\n\t\t\t\t{\r\n\t\t\t\t\tdropAllowed = Boolean.parse(row.getAttribute(\"nsDropAllowed\"));\r\n\t\t\t\t}\r\n\t\t\t\tif(dropAllowed) \r\n\t\t\t\t{\r\n\t\t\t\t\tvar offset = this.util.getCumulativeOffset(row);\r\n\t\t\t\t\tvar rowHeight = parseInt(row.offsetHeight)/2;\r\n\t\t\t\t\tif (row.offsetHeight === 0) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\toffset = this.util.getCumulativeOffset(row.firstChild);\r\n\t\t\t\t\t\trowHeight = parseInt(row.firstChild.offsetHeight)/2;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//console.log(\"yPos::\" + yPos + \",offset.y::\" + offset.y + \",rowHeight::\" + rowHeight);\r\n\t\t\t\t\t// Because we always have to insert before, we need to offset the height a bit\r\n\t\t\t\t\tif ((yPos > offset.y - rowHeight) && (yPos < (offset.y + rowHeight))) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treturn row;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tconsole.log(row.innerText);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn null;\r\n\t};\r\n\t\r\n\tNSTableRowMover.prototype.__setDivMovablePosition = function(posEvent)\r\n\t{\r\n\t\tif(this.__divMovable)\r\n\t {\r\n\t \tthis.__divMovable.style.left = posEvent.left + \"px\";\r\n\t \tthis.__divMovable.style.top = posEvent.top + \"px\";\r\n\t }\r\n\t};\r\n\t\r\n\tNSTableRowMover.prototype.__addDocumentEvents = function()\r\n\t{\r\n\t\tif(this.__touchSupport)\r\n\t\t{\r\n\t\t\tif(!this.__mouseMoveRef)\r\n\t\t\t{\r\n\t\t\t\tthis.__mouseMoveRef = this.__touchMoveHandler.bind(this);\r\n\t\t\t\tif(this.__config.isSameTableMove)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.util.addEvent(this.__config.table,\"touchmove\",this.__mouseMoveRef);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.util.addEvent(document,\"touchmove\",this.__mouseMoveRef);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif(!this.__documentMouseUpRef)\r\n\t\t\t{\r\n\t\t\t\tthis.__documentMouseUpRef = this.__documentTouchUpHandler.bind(this);\r\n\t\t\t\tthis.util.addEvent(document,\"touchend\",this.__documentMouseUpRef);\r\n\t\t\t}\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tif(!this.__mouseMoveRef)\r\n\t\t\t{\r\n\t\t\t\tthis.__mouseMoveRef = this.__mouseMoveHandler.bind(this);\r\n\t\t\t\tif(this.__config.isSameTableMove)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.util.addEvent(this.__config.table,\"mousemove\",this.__mouseMoveRef);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.util.addEvent(document,\"mousemove\",this.__mouseMoveRef);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif(!this.__documentMouseUpRef)\r\n\t\t\t{\r\n\t\t\t\tthis.__documentMouseUpRef = this.__documentMouseUpHandler.bind(this);\r\n\t\t\t\tthis.util.addEvent(document,\"mouseup\",this.__documentMouseUpRef);\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSTableRowMover.prototype.__removeDocumentEvents = function()\r\n\t{\r\n\t\tif(this.__mouseMoveRef)\r\n\t\t{\r\n\t\t\tthis.util.removeEvent(this.__config.table,\"mousemove\",this.__mouseMoveRef);\r\n\t\t\tthis.util.removeEvent(document,\"mousemove\",this.__mouseMoveRef);\r\n\t\t\tthis.__mouseMoveRef = null;\r\n\t\t}\r\n\t\tif(this.__documentMouseUpRef)\r\n\t\t{\r\n\t\t\tthis.util.removeEvent(document,\"mouseup\",this.__documentMouseUpRef);\r\n\t\t\tthis.__documentMouseUpRef = null;\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSTableRowMover.prototype.__createGhost = function(row)\r\n\t{\r\n\t\tif(this.__config.enableMovingText && !this.__divGhost)\r\n\t\t{\r\n\t\t\tvar html = this.__config.movingTextCallback ? this.__config.movingTextCallback(row) : row.cells[0].innerText;\r\n\t\t\tthis.__divGhost = this.util.createDiv(null,\"nsTableRowMoverGhost\");\r\n\t\t\tthis.__divGhost.innerHTML = html;\r\n\t this.__divGhost.style.height = '25px';\r\n\t this.__divGhost.style.top = '20px';\r\n\t this.__divGhost.style.left = '20px';\r\n\t document.body.appendChild(this.__divGhost);\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSTableRowMover.prototype.__removeGhost = function() \r\n\t{\r\n if (this.__divGhost && this.__divGhost.parentNode) \r\n {\r\n \tthis.__divGhost.parentNode.removeChild(this.__divGhost);\r\n }\r\n this.__divGhost = null;\r\n };\r\n \r\n NSTableRowMover.prototype.__positionGhost = function(event) \r\n\t{\r\n \tif(this.__divGhost)\r\n \t{\r\n \t\tevent = this.util.getEvent(event);\r\n \tvar ghostRect = this.__divGhost.getBoundingClientRect();\r\n var ghostHeight = ghostRect.height;\r\n var bodyDimension = this.util.getBodyDimension(); \r\n var browserWidth = bodyDimension.width - 2;\r\n var browserHeight = bodyDimension.height - 2;\r\n var top = event.pageY - (ghostHeight / 2);\r\n var left = event.pageX - 30;\r\n var windowScrollY = window.pageYOffset || document.documentElement.scrollTop;\r\n var windowScrollX = window.pageXOffset || document.documentElement.scrollLeft;\r\n if (browserWidth > 0) \r\n {\r\n if ((left + this.__divGhost.clientWidth) > (browserWidth + windowScrollX)) \r\n {\r\n left = browserWidth + windowScrollX - this.__divGhost.clientWidth;\r\n }\r\n }\r\n if (left < 0) \r\n {\r\n left = 0;\r\n }\r\n if (browserHeight > 0) \r\n {\r\n if ((top + this.__divGhost.clientHeight) > (browserHeight + windowScrollY)) \r\n {\r\n top = browserHeight + windowScrollY - this.__divGhost.clientHeight;\r\n }\r\n }\r\n if (top < 0) \r\n {\r\n top = 0;\r\n }\r\n this.__divGhost.style.left = left + 'px';\r\n this.__divGhost.style.top = top + 'px';\r\n \t}\r\n\t};\r\n\t\r\n\tNSTableRowMover.prototype.__applyCustomClass = function(element,type,defaultValue)\r\n\t{\r\n\t\tif(element)\r\n\t\t{\r\n\t\t\tif(type && this.__config.customClass[type])\r\n\t\t\t{\r\n\t\t\t\tthis.util.addStyleClass(element,this.__config.customClass[type]);\r\n\t\t\t}\r\n\t\t\telse if(defaultValue)\r\n\t\t\t{\r\n\t\t\t\tthis.util.addStyleClass(element,defaultValue);\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSTableRowMover.prototype.__removeCustomClass = function(element,type,defaultValue)\r\n\t{\r\n\t\tif(element)\r\n\t\t{\r\n\t\t\tif(type && this.__config.customClass[type])\r\n\t\t\t{\r\n\t\t\t\tthis.util.removeStyleClass(element,this.__config.customClass[type]);\r\n\t\t\t}\r\n\t\t\telse if(defaultValue)\r\n\t\t\t{\r\n\t\t\t\tthis.util.removeStyleClass(element,defaultValue);\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSTableRowMover.prototype.__getID = function()\r\n\t{\r\n\t\tif(!this.__id)\r\n\t\t{\r\n\t\t\tif(this.__config.table.hasAttribute(\"id\"))\r\n\t\t\t{\r\n\t\t\t\tthis.__id = this.__config.table.getAttribute(\"id\");\r\n\t\t\t}\r\n\t\t\telse if(this.__config.table.hasAttribute(\"name\"))\r\n\t\t\t{\r\n\t\t\t\tthis.__id = this.__config.table.getAttribute(\"name\");\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthis.__id = \"comp\" + this.util.getUniqueId();\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn this.__id;\r\n\t};\r\n\t\r\n\treturn NSTableRowMover;\r\n})();\r\nnsModuleExport(this,\"NSTableRowMover\",NSTableRowMover);";