UNPKG

ns-components-angular

Version:

Angular Wrapper Components for NSComponents

1 lines 64.8 kB
export declare const NSPlugginsCode = "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\n\r\n\t\t}\r\nvar nsTextEditor = (function()\r\n{\r\n\tfunction nsTextEditor(setting,util) \r\n\t{\r\n\t var input;\r\n\t var defaultValue;\r\n\t var self = this;\r\n\t var prevHtml = null;\r\n\t \r\n\t this.init = function() \r\n\t {\r\n\t \tprevHtml = setting.container.innerHTML;\r\n\t \tsetting.container.innerHTML = \"\";\r\n\t \tinput = util.createElement(\"input\",null,\"nsTextEditor\"); \r\n\t \tsetting.container.appendChild(input);\r\n\t \tutil.addEvent(input,\"keydown\",this.handleKeyDown);\r\n\t \tutil.addEvent(input,\"click\",function(event){\r\n\t \t\tevent = util.getEvent(event);\r\n\t \t\tself.setFocus();\r\n\t \t\tevent.stopPropagation();\r\n\t \t\tevent.stopImmediatePropagation();\r\n\t \t\tevent.preventDefault();\r\n\t \t});\r\n\t \tdefaultValue = setting.defaultValue;\r\n\t \tinput.value = defaultValue;\r\n\t \tinput.focus();\r\n\t \tinput.select();\r\n\t };\r\n\t \r\n\t this.handleKeyDown = function(event) \r\n\t {\r\n\t \tevent = util.getEvent(event);\r\n\t \tvar keyCode = util.KEYCODE;\r\n\t \tif (event.keyCode == keyCode.LEFT && event.keyCode == keyCode.RIGHT) \r\n\t \t{\r\n\t \t\tevent.stopImmediatePropagation();\r\n\t \t} \r\n\t \tif (event.keyCode == keyCode.ENTER) \r\n\t \t{\r\n\t \tself.save();\r\n\t \t}\r\n\t \telse if (event.keyCode == keyCode.TAB) \r\n\t \t{\r\n\t \t\tself.save();\r\n\t \t\tevent.preventDefault();\r\n\t \t}\r\n\t \telse if (event.keyCode == keyCode.ESC) \r\n\t \t{\r\n\t \tself.cancel();\r\n\t \tevent.preventDefault();\r\n\t \t} \r\n\t };\r\n\t \r\n\t this.save = function() \r\n\t {\r\n\t \tsetting.commitChanges(self.getValue());\r\n\t };\r\n\t\r\n\t this.cancel = function() \r\n\t {\r\n\t \tinput.value = defaultValue;\r\n\t \tsetting.cancelChanges();\r\n\t };\r\n\t\r\n\t this.destroy = function() \r\n\t {\r\n\t \tif(input && input.parentNode)\r\n\t \t{\r\n\t \t\tinput.parentNode.removeChild(input);\r\n\t \t}\r\n\t \tsetting.container.innerHTML = prevHtml;\r\n\t };\r\n\t\r\n\t this.getValue = function() \r\n\t {\r\n\t \treturn input.value;\r\n\t };\r\n\t \r\n\t this.setFocus = function()\r\n\t {\r\n\t \tinput.focus();\r\n\t \t//setTimeout(function(){input.selectionStart = input.selectionEnd = 10000; }, 0);\r\n\t \tinput.selectionEnd = input.selectionStart = input.value.length;\r\n\t };\r\n\t\r\n\t this.hasValueChanged = function() \r\n\t {\r\n\t \treturn (!(input.value == \"\" && defaultValue == null)) && (input.value != defaultValue);\r\n\t };\r\n\t\t\r\n\t this.validate = function() \r\n\t {\r\n\t \tif(setting.validator)\r\n\t \t{\r\n\t \t\treturn setting.validator(input.value);\r\n\t \t}\r\n\t \treturn {isValid:true,message:null};\r\n\t };\r\n\t\r\n\t this.init();\r\n\t};\r\n\treturn nsTextEditor;\r\n})();\r\nnsModuleExport(this,\"nsTextEditor\",nsTextEditor);\r\n\r\nvar nsTextAreaEditor = (function()\r\n{\r\n\tfunction nsTextAreaEditor(setting,util) \r\n\t{\r\n\t var input, wrapper;\r\n\t var defaultValue;\r\n\t var self = this;\r\n\t\t\r\n\t this.init = function () \r\n\t {\r\n\t \tvar container = document.body;\r\n\t \twrapper = util.createDiv(null,\"nsTextAreaEditor\");\r\n\t \tinput = util.createElement(\"textarea\",null,\"nsTextArea\"); \r\n\t \tinput.setAttribute(\"hidefocus\",true);\r\n\t \tinput.setAttribute(\"rows\",5);\r\n\t \tutil.addEvent(input,\"keydown\",this.handleKeyDown);\r\n\t \twrapper.appendChild(input);\r\n\t \twrapper.appendChild(document.createElement(\"br\"));\r\n\t \tvar buttonWrapper = util.createDiv(null);\r\n\t \tbuttonWrapper.style.textAlign = \"right\";\r\n\t \twrapper.appendChild(buttonWrapper);\r\n\t \tvar btnSave = util.createElement(\"button\");\r\n\t \tbtnSave.appendChild(document.createTextNode(\"Save\"));\r\n\t \tutil.addEvent(btnSave,\"click\",this.save);\r\n\t \tbuttonWrapper.appendChild(btnSave);\r\n\t \tbuttonWrapper.appendChild(document.createTextNode(\" \"));\r\n\t \tvar btnCancel = util.createElement(\"button\");\r\n\t \tbtnCancel.appendChild(document.createTextNode(\"Cancel\"));\r\n\t \tbuttonWrapper.appendChild(btnCancel);\r\n\t \tutil.addEvent(btnCancel,\"click\",this.cancel);\r\n\t \tcontainer.appendChild(wrapper);\t\r\n\t \tself.position(setting.position);\r\n\t \tdefaultValue = setting.defaultValue;\r\n\t \tinput.value = defaultValue;\r\n\t \tinput.focus();\r\n\t \tinput.select();\r\n\t };\r\n\t\r\n\t this.handleKeyDown = function(event) \r\n\t {\r\n\t \tevent = util.getEvent(event);\r\n\t \tvar keyCode = util.KEYCODE;\r\n\t \tif (event.keyCode == keyCode.ENTER && event.ctrlKey) \r\n\t \t{\r\n\t \tself.save();\r\n\t \t} \r\n\t \telse if (event.keyCode == keyCode.ESC) \r\n\t \t{\r\n\t \tself.cancel();\r\n\t \tevent.preventDefault();\r\n\t \t} \r\n\t \telse if (event.keyCode == keyCode.TAB) \r\n\t \t{\r\n\t \t\tself.cancel();\r\n\t \t\tevent.preventDefault();\r\n\t \t}\r\n\t };\r\n\t\r\n\t this.save = function () \r\n\t {\r\n\t \tsetting.commitChanges(self.getValue());\r\n\t };\r\n\t\r\n\t this.cancel = function () \r\n\t {\r\n\t \tinput.value = defaultValue;\r\n\t \tsetting.cancelChanges();\r\n\t };\r\n\t\r\n\t this.position = function(position) \r\n\t {\r\n\t \twrapper.style.top = (position.top - 5) + \"px\";\r\n\t \twrapper.style.left = (position.left - 5) + \"px\";\r\n\t };\r\n\t\r\n\t this.destroy = function() \r\n\t {\r\n\t \twrapper.parentNode.removeChild(wrapper);\r\n\t };\r\n\t\r\n\t this.getValue = function() \r\n\t {\r\n\t \treturn input.value;\r\n\t };\r\n\t \r\n\t this.setFocus = function()\r\n\t {\r\n\t \tinput.focus();\r\n\t };\r\n\t\r\n\t this.hasValueChanged = function() \r\n\t {\r\n\t \treturn (!(input.value == \"\" && defaultValue == null)) && (input.value != defaultValue);\r\n\t };\r\n\t\r\n\t this.validate = function() \r\n\t {\r\n\t \tif(setting.validator)\r\n\t \t{\r\n\t \t\treturn setting.validator(input.value);\r\n\t \t}\r\n\t \treturn {isValid:true,message:null};\r\n\t };\r\n\t\r\n\t this.init();\r\n\t}\r\n\treturn nsTextAreaEditor;\r\n})();\r\nnsModuleExport(this,\"nsTextAreaEditor\",nsTextAreaEditor);\r\n\r\nvar NSCellSelection = (function()\r\n{\r\n\tvar NSCellSelection = function(table,setting)\r\n\t{\r\n\t\tthis.__table = table;\r\n\t\tthis.__setting = setting;\r\n\t\tthis.util = new NSUtil();\r\n\t\tthis.__tblBody = null;\r\n\t\tthis.__scrollableElement = null;\r\n\t\tthis.__config = null;\r\n\t\tthis.__initDone = false;\r\n\t\t\r\n\t\tthis.__hasFocus = false;\r\n\t\tthis.__range = null;\r\n\t\tthis.__deltaX = 0;\r\n\t\tthis.__deltaY = 0;\r\n\t\tthis.__selectedCell = null;\r\n\t\tthis.__lastDirection = null;\r\n\t\tthis.__handle = null;\r\n\t\tthis.__lastEditor = null;\r\n\t\tthis.__isHandleDragged = false;\r\n\t\t\r\n\t\tthis.__tblMouseDownRef = null;\r\n\t\tthis.__tblMouseMoveRef = null;\r\n\t\tthis.__tblClickRef = null;\r\n\t\tthis.__tbldblClickRef = null;\r\n\t\tthis.__documentMouseDownRef = null;\r\n\t\tthis.__documentMouseUpRef = null;\r\n\t\tthis.__documentMouseMoveRef = null;\r\n\t\tthis.__documentKeyEventRef = null;\r\n\t\tthis.__documentCopyRef = null;\r\n\t\tthis.__documentPasteRef = null;\r\n\t\t\r\n\t\tthis.__initialize = function()\r\n\t\t{\r\n\t\t\tif(this.__table && this.__table.tBodies && this.__table.tBodies.length > 0 && this.__table.tBodies[0].rows.length > 0)\r\n\t\t\t{\r\n\t\t\t\tthis.util.addStyleClass(this.__table,\"nsSelectionTable\");\r\n\t\t\t\tthis.__tblBody = this.__table.tBodies[0];\r\n\t\t\t\tif(!this.__setting)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__setting = {};\r\n\t\t\t\t}\r\n\t\t\t\tvar self = this;\r\n\t\t\t\tthis.__config = {\r\n\t\t\t\t\t\tscrollableElement: this.__setting[\"scrollableElement\"] || this.__table.parentNode,\r\n\t\t\t\t\t\tenableFillHandle: Boolean.parse(this.__setting[\"enableFillHandle\"]),\r\n\t\t\t\t\t\tenableKeyboardNavigation: Boolean.parse(this.__setting[\"enableKeyboardNavigation\"]),\r\n\t\t\t\t\t\tenableCopy: Boolean.parse(this.__setting[\"enableCopy\"]),\r\n\t\t\t\t\t\tenablePaste: Boolean.parse(this.__setting[\"enablePaste\"]),\r\n\t\t\t\t\t\tcellClass: this.__setting[\"cellClass\"] || \"nsCell\",\r\n\t\t\t\t\t\tareaClass: this.__setting[\"areaClass\"] || \"nsArea\",\r\n\t\t\t\t\t\teditors: this.__setting[\"editors\"] || []\r\n\t\t\t\t};\r\n\t\t\t\tthis.__config[\"areaClassLeft\"] = this.__setting[\"areaClassLeft\"] || (this.__config.areaClass + \"-left\");\r\n\t\t\t\tthis.__config[\"areaClassRight\"] = this.__setting[\"areaClassRight\"] || (this.__config.areaClass + \"-right\");\r\n\t\t\t\tthis.__config[\"areaClassTop\"] = this.__setting[\"areaClassTop\"] || (this.__config.areaClass + \"-top\");\r\n\t\t\t\tthis.__config[\"areaClassBottom\"] = this.__setting[\"areaClassBottom\"] || (this.__config.areaClass + \"-bottom\");\r\n\t\t\t\t\r\n\t\t\t\tvar colLength = this.__tblBody.rows[0].cells.length;\r\n\t\t\t\tvar editors = this.__config.editors;\r\n\t\t\t\tfor(var count = 0;count < colLength;count++)\r\n\t\t\t\t{\r\n\t\t\t\t\tif(editors.length > count)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar editor = editors[count] || {};\r\n\t\t\t\t\t\tif(!editor.type && !editor.customEditor)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\teditors.push({\"type\":NSCellSelection.EDITORS.TEXT});\r\n\t\t\t\t\t\t}\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\teditors.push({\"type\":NSCellSelection.EDITORS.TEXT});\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tthis.__scrollableElement = this.__config.scrollableElement;\r\n\t\t\t\tthis.__range = {cursor:null,start:null,topLeft:null,bottomRight:null};\r\n\t\t\t\tif(this.__config.enableFillHandle)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__createHandle();\r\n\t\t\t\t}\r\n\t\t\t\tif(!this.__tblMouseDownRef && !this.__config.enableFillHandle)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__tblMouseDownRef = this.__tblMouseDownHandler.bind(this);\r\n\t\t\t\t\tthis.util.addEvent(this.__table,\"mousedown\", this.__tblMouseDownRef);\r\n\t\t\t\t}\r\n\t\t\t\tif(!this.__tblClickRef)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__tblClickRef = this.__tblClickHandler.bind(this);\r\n\t\t\t\t\tthis.util.addEvent(this.__table,\"click\", this.__tblClickRef);\r\n\t\t\t\t}\r\n\t\t\t\tif(!this.__tbldblClickRef)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__tbldblClickRef = this.__tbldblClickHandler.bind(this);\r\n\t\t\t\t\tthis.util.addEvent(this.__table,\"dblclick\", this.__tbldblClickRef);\r\n\t\t\t\t}\r\n\t\t\t\tif(!this.__documentMouseDownRef)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__documentMouseDownRef = this.__documentMouseDownHandler.bind(this);\r\n\t\t\t\t\tthis.util.addEvent(document,\"mousedown\", this.__documentMouseDownRef);\r\n\t\t\t\t}\r\n\t\t\t\tif(!this.__documentKeyEventRef && this.__config.enableKeyboardNavigation)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__documentKeyEventRef = this.__documentKeyEventHandler.bind(this);\r\n\t\t\t\t\tthis.util.addEvent(document,\"keypress\", this.__documentKeyEventRef);\r\n\t\t\t\t\tthis.util.addEvent(document,\"keyup\", this.__documentKeyEventRef);\r\n\t\t\t\t\tthis.util.addEvent(document,\"keydown\", this.__documentKeyEventRef);\r\n\t\t\t\t}\r\n\t\t\t\tif(!this.__documentCopyRef && this.__config.enableCopy)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__documentCopyRef = this.__documentCopyHandler.bind(this);\r\n\t\t\t\t\tthis.util.addEvent(document,\"copy\", this.__documentCopyRef);\r\n\t\t\t\t}\r\n\t\t\t\tif(!this.__documentPasteRef && this.__config.enablePaste)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__documentPasteRef = this.__documentPasteHandler.bind(this);\r\n\t\t\t\t\tthis.util.addEvent(document,\"paste\", this.__documentPasteRef);\r\n\t\t\t\t}\r\n\t\t\t\tthis.__initDone = true;\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.getSelectedRows = function()\r\n\t\t{\r\n\t\t\tvar arrReturn = [];\r\n\t\t\tif(this.__range.cursor) \r\n\t\t {\r\n\t\t\t\tvar range = this.__range;\r\n\t\t\t\tvar arrRows = this.__tblBody.rows;\r\n\t\t\t\tvar length = range.bottomRight.row;\r\n\t\t\t\tfor(var count = range.topLeft.row;count <= length;count++)\r\n\t\t\t\t{\r\n\t\t\t\t if(arrRows[count])\r\n\t\t\t\t {\r\n\t\t\t\t \t\tarrReturn.push({rowIndex:count,row:arrRows[count]});\r\n\t\t\t\t }\r\n\t\t\t\t else\r\n\t\t\t\t {\r\n\t\t\t\t \tbreak;\r\n\t\t\t\t }\r\n\t\t\t\t}\r\n\t\t }\r\n\t\t\treturn arrReturn;\r\n\t\t};\r\n\t\t\r\n\t\tthis.getSelectedRowsCells = function()\r\n\t\t{\r\n\t\t\tvar arrReturn = [];\r\n\t\t\tif(this.__range.cursor) \r\n\t\t {\r\n\t\t\t\tvar range = this.__range;\r\n\t\t\t\tvar arrRows = this.getSelectedRows();\r\n\t\t\t\tvar length = arrRows.length;\r\n\t\t\t\tvar arrCells = [];\r\n\t\t\t\tvar arrSelectedCells = [];\r\n\t\t\t\tvar cellLength = range.bottomRight.col;\r\n\t\t\t\tvar row = null;\r\n\t\t\t\tfor(var count = 0;count < length;count++)\r\n\t\t\t\t{\r\n\t\t\t\t\trow = arrRows[count].row;\r\n\t\t\t\t\tarrCells = row.cells;\r\n\t\t\t\t\tarrSelectedCells = [];\r\n\t\t\t\t for(var innerCount = range.topLeft.col;innerCount <= cellLength;innerCount++)\r\n\t\t\t\t {\r\n\t\t\t\t \tarrSelectedCells.push({rowIndex:arrRows[count].rowIndex,row:row,cellIndex:innerCount,cell:arrCells[innerCount]});\r\n\t\t\t\t }\r\n\t\t\t\t arrReturn.push({rowIndex:arrRows[count].rowIndex,row:row,cellDetails:arrSelectedCells});\r\n\t\t\t\t}\r\n\t\t }\r\n\t\t\treturn arrReturn;\r\n\t\t};\r\n\t\t\r\n\t\tthis.getSelectedCellValues = function()\r\n\t\t{\r\n\t\t\tvar arrReturn = [];\r\n\t\t\tvar arrDetail = this.getSelectedRowsCells();\r\n\t\t\tvar arrValues = [];\r\n\t\t\tfor(var rowCount = 0;rowCount < arrDetail.length;rowCount++)\r\n\t\t\t{\r\n\t\t\t var arrCellDetails = arrDetail[rowCount].cellDetails;\r\n\t\t\t var arrValues = [];\r\n\t\t\t for(var cellCount = 0;cellCount < arrCellDetails.length;cellCount++)\r\n\t\t\t {\r\n\t\t\t \tarrValues.push(arrCellDetails[cellCount].cell.innerText);\r\n\t\t\t\t}\r\n\t\t\t arrReturn.push(arrValues);\r\n\t\t\t}\r\n\t\t\treturn arrReturn;\r\n\t\t};\r\n\t\t\r\n\t\tthis.setSelectedCellValues = function(arrValues)\r\n\t\t{\r\n\t\t\tif(arrValues)\r\n\t\t\t{\r\n\t\t\t\tif(!this.util.isArray(arrValues))\r\n\t\t\t\t{\r\n\t\t\t\t\tarrValues = [arrValues];\r\n\t\t\t\t}\r\n\t\t\t\tvar arrDetail = this.getSelectedRowsCells();\r\n\t\t\t\tfor(var rowCount = 0;rowCount < arrDetail.length && (rowCount in arrValues);rowCount++)\r\n\t\t\t\t{\r\n\t\t\t\t var arrCellDetails = arrDetail[rowCount].cellDetails;\r\n\t\t\t\t var value = arrValues[rowCount];\r\n\t\t\t\t if(!this.util.isArray(value))\r\n\t\t\t\t\t{\r\n\t\t\t\t \tvalue = [value];\r\n\t\t\t\t\t}\r\n\t\t\t\t for(var cellCount = 0;cellCount < arrCellDetails.length && (cellCount in value);cellCount++)\r\n\t\t\t\t {\r\n\t\t\t\t \tthis.setCellValue(arrCellDetails[cellCount].cell,value[cellCount]);\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\t\r\n\t\tthis.setCellValue = function(cell,data)\r\n\t\t{\r\n\t\t\tif(cell)\r\n\t\t\t{\r\n\t\t\t\tvar row = this.util.findParent(cell,\"tr\");\r\n\t\t\t\tthis.util.dispatchEvent(this.__table,NSCellSelection.SET_CELL_VALUE,cell,{cellIndex:cell.cellIndex,rowIndex:row.rowIndex,cell:cell,row:row,dataToBeSet:data});\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.selectAll = function()\r\n\t\t{\r\n\t\t\tthis.__selectCell({row:0,col:0},{row:-1,col:-1});\r\n\t\t\tthis.__refreshCells();\r\n\t\t\tthis.__refreshPosition();\r\n\t\t};\r\n\t\t\r\n\t\tthis.deselectAll = function()\r\n\t\t{\r\n\t\t\tthis.__deSelectCurrentRange();\r\n\t\t\tthis.__refreshCells();\r\n\t\t\tthis.__refreshPosition();\r\n\t\t};\r\n\t\t\r\n\t\tthis.selectRange = function(fromRange,toTange)\r\n\t\t{\r\n\t\t\tif(fromRange && toTange)\r\n\t\t\t{\r\n\t\t\t\tthis.__selectCell(fromRange,toTange);\r\n\t\t\t\tthis.__refreshCells();\r\n\t\t\t\tthis.__refreshPosition();\t\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.selectCell = function(cellRange)\r\n\t\t{\r\n\t\t\tif(cellRange)\r\n\t\t\t{\r\n\t\t\t\tthis.__selectCell(cellRange);\r\n\t\t\t\tthis.__refreshCells();\r\n\t\t\t\tthis.__refreshPosition();\t\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.destroy = function()\r\n\t\t{\r\n\t\t\tif(this.__initDone)\r\n\t\t\t{\r\n\t\t\t\tthis.deselectAll();\r\n\t\t\t\tif(this.__tblMouseDownRef)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.util.removeEvent(this.__table,\"mousedown\", this.__tblMouseDownRef);\r\n\t\t\t\t\tthis.__tblMouseDownRef = null;\r\n\t\t\t\t}\r\n\t\t\t\tif(this.__tblClickRef)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.util.removeEvent(this.__table,\"click\", this.__tblClickRef);\r\n\t\t\t\t\tthis.__tblClickRef = null;\r\n\t\t\t\t}\r\n\t\t\t\tif(this.__tbldblClickRef)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.util.removeEvent(this.__table,\"dblclick\", this.__tbldblClickRef);\r\n\t\t\t\t\tthis.__tbldblClickRef = null;\r\n\t\t\t\t}\r\n\t\t\t\tif(this.__tblMouseMoveRef)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.util.removeEvent(this.__table,\"mousemove\", this.__tblMouseMoveRef);\r\n\t\t\t\t\tthis.__tblMouseMoveRef = null;\r\n\t\t\t\t}\r\n\t\t\t\tif(this.__documentMouseDownRef)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.util.removeEvent(document,\"mousedown\", this.__documentMouseDownRef);\r\n\t\t\t\t\tthis.__documentMouseDownRef = null;\r\n\t\t\t\t}\r\n\t\t\t\tif(this.__documentMouseUpRef)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.util.removeEvent(document,\"mouseup\", this.__documentMouseUpRef);\r\n\t\t\t\t\tthis.__documentMouseUpRef = null;\r\n\t\t\t\t}\r\n\t\t if(this.__documentMouseMoveRef)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.util.removeEvent(document,\"mousemove\", this.__documentMouseMoveRef);\r\n\t\t\t\t\tthis.__documentMouseMoveRef = null;\r\n\t\t\t\t}\r\n\t\t\t\tif(this.__documentKeyEventRef)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.util.removeEvent(document,\"keypress\", this.__documentKeyEventRef);\r\n\t\t\t\t\tthis.util.removeEvent(document,\"keyup\", this.__documentKeyEventRef);\r\n\t\t\t\t\tthis.util.removeEvent(document,\"keydown\", this.__documentKeyEventRef);\r\n\t\t\t\t\tthis.__documentKeyEventRef = null;\r\n\t\t\t\t}\r\n\t\t\t\tif(this.__documentCopyRef)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.util.removeEvent(document,\"copy\", this.__documentCopyRef);\r\n\t\t\t\t\tthis.__documentCopyRef = null;\r\n\t\t\t\t}\r\n\t\t\t\tif(this.__documentPasteRef)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.util.removeEvent(document,\"paste\", this.__documentPasteRef);\r\n\t\t\t\t\tthis.__documentPasteRef = null;\r\n\t\t\t\t}\r\n\t\t\t\tthis.__initDone = false;\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__tblMouseDownHandler = function(event)\r\n\t\t{\r\n\t\t\tif(!this.__lastEditor)\r\n\t\t\t{\r\n\t\t\t\tevent = this.util.getEvent(event);\r\n\t\t\t\tvar target = this.util.getTarget(event);\r\n\t\t\t\t//var cell = this.__closestCell(target);\r\n\t\t\t\tvar cell = this.util.findParent(target,\"TD\");\r\n\t\t if(cell)\r\n\t\t {\r\n\t\t \tthis.__fireSelectionStartEvent();\r\n\t\t \tthis.__selectedCell = cell;\r\n\t\t \tvar position = this.__getCellPosition(cell);\r\n\t\t\t this.__selectCell(position,event.shiftKey);\r\n\t\t\t event.preventDefault();\r\n\t\t\t this.__refreshCells();\r\n\t\t }\r\n\t\t if(!this.__documentMouseUpRef)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__documentMouseUpRef = this.__documentMouseUpHandler.bind(this);\r\n\t\t\t\t\tthis.util.addEvent(document,\"mouseup\", this.__documentMouseUpRef);\r\n\t\t\t\t}\r\n\t\t if(!this.__documentMouseMoveRef)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__documentMouseMoveRef = this.__documentMouseMoveHandler.bind(this);\r\n\t\t\t\t\tthis.util.addEvent(document,\"mousemove\", this.__documentMouseMoveRef);\r\n\t\t\t\t}\r\n\t\t if(!this.__tblMouseMoveRef)\r\n\t\t\t\t{\r\n\t\t \tthis.__tblMouseMoveRef = this.__tblMouseMoveHandler.bind(this);\r\n\t\t\t\t\tthis.util.addEvent(this.__table,\"mousemove\", this.__tblMouseMoveRef);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__tblMouseMoveHandler = function(event)\r\n\t\t{\r\n\t\t\tthis.__movingHandler(event);\r\n\t\t};\r\n\t\t\r\n\t\tthis.__tblClickHandler = function(event)\r\n\t\t{\r\n\t\t\tevent = this.util.getEvent(event);\r\n\t\t\tvar target = this.util.getTarget(event);\r\n\t\t\tvar cell = this.util.findParent(target,\"TD\");\r\n\t\t\tif (!cell || (this.__lastEditor && this.__lastEditor.__cell == cell)) \r\n\t\t\t{\r\n\t\t\t\tif(this.__lastEditor)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__lastEditor.setFocus();\t\r\n\t\t\t\t}\r\n\t\t return;\r\n\t\t }\r\n\t\t\tif (this.__lastEditor && this.__lastEditor.__cell != cell) \r\n\t\t\t{\r\n\t\t\t\tthis.__commitEditorChanges(this.__lastEditor);\r\n\t\t }\r\n\t\t\tif(this.__config.enableFillHandle && cell)\r\n\t\t\t{\r\n\t \tthis.__fireSelectionStartEvent();\r\n\t \tthis.__selectedCell = cell;\r\n\t \tvar position = this.__getCellPosition(cell);\r\n\t\t this.__selectCell(position,event.shiftKey);\r\n\t\t event.preventDefault();\r\n\t\t this.__refreshCells();\r\n\t\t\t\tthis.__repositionHandle(cell);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__tbldblClickHandler = function(event)\r\n\t\t{\r\n\t\t\tevent = this.util.getEvent(event);\r\n\t\t\tvar target = this.util.getTarget(event);\r\n\t\t\tvar cell = this.util.findParent(target,\"TD\");\r\n\t\t\tif(!this.__lastEditor || (this.__lastEditor && this.__lastEditor.__cell != cell))//if(this.__selectedCell != cell)\r\n\t\t\t{\r\n\t\t\t\tthis.__selectedCell = cell;\r\n\t\t\t\tthis.__handleEditor(this.__selectedCell,event);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__documentMouseDownHandler = function(event)\r\n\t\t{\r\n\t\t\tevent = this.util.getEvent(event);\r\n\t\t\tvar target = this.util.getTarget(event);\r\n\t\t\tif(this.__setFocus(this.__table === target || (this.__table.compareDocumentPosition(target) & Node.DOCUMENT_POSITION_CONTAINED_BY)))\r\n\t\t\t{\r\n\t\t \t//scope.$apply();\r\n\t\t }\r\n\t\t};\r\n\t\t\r\n\t\tthis.__documentMouseMoveHandler = function(event)\r\n\t\t{\r\n\t\t\tthis.__repositionScrolls(event,true,true);\r\n\t\t};\r\n\t\t\r\n\t\tthis.__documentMouseUpHandler = function(event)\r\n\t\t{\r\n\t\t\tif(this.__documentMouseMoveRef)\r\n\t\t\t{\r\n\t\t\t\tthis.util.removeEvent(document,\"mousemove\",this.__documentMouseMoveRef);\r\n\t\t\t\tthis.__documentMouseMoveRef = null;\r\n\t\t\t}\r\n\t\t\tif(this.__documentMouseUpRef)\r\n\t\t\t{\r\n\t\t\t\tthis.util.removeEvent(document,\"mouseup\", this.__documentMouseUpRef);\r\n\t\t\t\tthis.__documentMouseUpRef = null;\r\n\t\t\t}\r\n\t\t\tif(this.__tblMouseMoveRef)\r\n\t\t\t{\r\n\t\t\t\tthis.util.removeEvent(this.__table,\"mousemove\",this.__tblMouseMoveRef);\r\n\t\t\t\tthis.__tblMouseMoveRef = null;\r\n\t\t\t}\r\n\t\t\t/*if(this.__handleDragRef)\r\n\t\t\t{\r\n\t\t\t\tthis.util.removeEvent(this.__table,\"mousemove\", this.__handleDragRef);\r\n\t\t\t\tthis.__handleDragRef = null;\r\n\t\t\t}*/\r\n\t\t\tthis.__deltaX = 0;\r\n\t\t\tthis.__deltaY = 0;\r\n\t\t\tthis.__fireSelectionEndEvent();\r\n\t\t};\r\n\t\t\r\n\t\tthis.__documentKeyEventHandler = function(event)\r\n\t\t{\r\n\t\t\tif(this.__hasFocus)\r\n\t\t\t{\r\n\t\t\t\tevent = this.util.getEvent(event);\r\n\t\t\t\tvar target = this.util.getTarget(event);\r\n\t\t\t\tif(!this.__isKeyStrokeValid(target,this.__table))\r\n\t\t\t\t{\r\n\t\t\t\t\tif(event.type == \"keydown\")\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif(event.keyCode === this.util.KEYCODE.ENTER)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tthis.__handleEditor(this.__selectedCell,event);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse if(this.__KeyMoveHandler(event))\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tthis.__fireSelectionStartEvent();\r\n\t\t\t\t\t\t\tthis.__refreshCells();\r\n\t\t\t\t\t\t\tthis.__refreshPosition(event);\r\n\t\t\t\t\t\t\tevent.stopImmediatePropagation();\r\n\t\t\t\t\t\t\tevent.preventDefault();\r\n\t\t\t\t\t\t\tthis.__fireSelectionEndEvent();\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};\r\n\t\t\r\n\t\tthis.__documentCopyHandler = function(event)\r\n\t\t{\r\n\t\t\tif(this.__hasFocus)\r\n\t\t\t{\r\n\t\t\t\tevent = this.util.getEvent(event);\r\n\t\t\t\tvar clipboardData = (event.clipboardData || event.originalEvent && event.originalEvent.clipboardData);\r\n\t\t\t\tvar arrData = this.getSelectedCellValues();\r\n\t\t\t\tvar data = this.__formatDataForCopy(arrData);\r\n\t\t\t\tif(clipboardData)\r\n\t\t\t\t{\r\n\t\t\t\t\tclipboardData.setData(\"text/plain\", data);\r\n\t\t\t\t\tevent.preventDefault();\r\n\t\t }\r\n\t\t\t\telse if(window.clipboardData)\r\n\t\t\t\t{\r\n\t\t\t\t\twindow.clipboardData.setData(\"Text\", data);\r\n\t\t \tevent.preventDefault();\r\n\t\t }\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__documentPasteHandler = function(event)\r\n\t\t{\r\n\t\t\tif(this.__hasFocus)\r\n\t\t\t{\r\n\t\t\t\tevent = this.util.getEvent(event);\r\n\t\t\t\tvar clipboardData = (event.clipboardData || event.originalEvent && event.originalEvent.clipboardData);\r\n\t\t\t\tvar data = null;\r\n\t\t\t\tif(clipboardData)\r\n\t\t\t\t{\r\n\t\t\t \tdata = clipboardData.getData(\"text/plain\");\r\n\t\t\t }\r\n\t\t\t\telse if(window.clipboardData)\r\n\t\t\t\t{\r\n\t\t\t data = window.clipboardData.getData(\"Text\");\r\n\t\t\t }\r\n\t\t\t\tif(!this.util.isUndefined(data))\r\n\t\t\t\t{\r\n\t\t\t\t\tdata = this.__formatDataForPaste(data);\r\n\t\t\t\t\tthis.setSelectedCellValues(data);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__createHandle = function()\r\n\t\t{\r\n\t\t\tif(!this.__handle)\r\n\t\t\t{\r\n\t\t\t\tthis.__handle = this.util.createDiv(null,\"handle-overlay\");\r\n\t\t\t\tthis.__handle.setAttribute(\"draggable\",true);\r\n\t\t\t\tthis.__table.parentNode.appendChild(this.__handle);\r\n\t\t\t\tif(!this.__handleDragStartRef)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__handleDragStartRef = this.__handleDragStartHandler.bind(this);\r\n\t\t\t\t\t//this.util.addEvent(this.__handle,\"mousedown\", this.__handleDragStartRef);\r\n\t\t\t\t\tthis.util.addEvent(this.__handle,\"dragstart\", this.__handleDragStartRef);\r\n\t\t\t\t}\r\n\t\t\t\tif(!this.__handleDragRef)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__handleDragRef = this.__handleDragHandler.bind(this);\r\n\t\t\t\t\tthis.util.addEvent(this.__handle,\"drag\", this.__handleDragRef);\r\n\t\t\t\t}\r\n\t\t\t\tif(!this.__handleDragEndRef)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__handleDragEndRef = this.__handleDragEndHandler.bind(this);\r\n\t\t\t\t\tthis.util.addEvent(this.__handle,\"dragend\", this.__handleDragEndRef);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__handleDragStartHandler = function(event)\r\n\t\t{\r\n\t\t\tif(!this.__lastEditor)\r\n\t\t\t{\r\n\t\t\t\tevent = this.util.getEvent(event);\r\n\t\t\t\tvar target = this.util.getTarget(event);\r\n\t\t\t\tvar cell = this.__getCellFromDragPosition(event);\r\n\t\t\t\t//var cell = this.__closestCell(target);\r\n\t\t if(cell)\r\n\t\t {\r\n\t\t \tif(this.__isCellSelectionValid(cell))\r\n\t\t\t \t\t{\r\n\t\t \t\tthis.__fireSelectionStartEvent();\r\n\t\t\t \tthis.__selectedCell = cell;\r\n\t\t\t \tvar position = this.__getCellPosition(cell);\r\n\t\t\t\t this.__selectCell(position,event.shiftKey);\r\n\t\t\t\t this.__refreshCells();\r\n\t\t\t\t this.__repositionHandle(cell);\r\n\t\t\t\t event.stopImmediatePropagation();\r\n\t\t\t\t this.__isHandleDragged = true;\r\n\t\t\t \t\t}\r\n\t\t \telse\r\n\t\t \t{\r\n\t\t \t\tthis.__isHandleDragged = false;\r\n\t\t \t\tevent.preventDefault();\r\n\t\t \t}\r\n\t\t }\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__handleDragHandler = function(event)\r\n\t\t{\r\n\t\t\tif(this.__isHandleDragged)\r\n\t\t\t{\r\n\t\t\t\tthis.__movingHandler(event);\r\n\t\t\t\tthis.__repositionScrolls(event,true,false);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__handleDragEndHandler = function(event)\r\n\t\t{\r\n\t\t\tif(this.__isHandleDragged)\r\n\t\t\t{\r\n\t\t\t\tthis.__deltaX = 0;\r\n\t\t\t\tthis.__deltaY = 0;\r\n\t\t\t\tthis.__fireSelectionEndEvent();\r\n\t\t\t}\r\n\t\t\tthis.__isHandleDragged = false;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__repositionHandle = function(cell)\r\n\t\t{\r\n\t\t\tif(cell && this.__handle)\r\n\t\t\t{\r\n\t\t\t\tvar rect = cell.getBoundingClientRect();\r\n\t\t\t var newOffset = this.util.getPosition(cell,true);\r\n\t\t\t this.__handle.style.top = (newOffset.top + rect.height - 4) + \"px\";\r\n\t\t\t this.__handle.style.left = ((newOffset.left + rect.width) - 4) + \"px\";\r\n\t\t\t this.__handle.style.height = \"1px\";\r\n\t\t\t this.__handle.style.width = \"1px\";\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__handleEditor = function(cell,event)\r\n\t\t{\r\n\t\t\tif(cell)\r\n\t\t\t{\r\n\t\t\t\tvar self = this;\r\n\t\t\t\tvar commitChanges = function(value)\r\n\t\t\t\t{\r\n\t\t\t\t\tself.__commitEditorChanges(editor);\r\n\t\t\t\t};\r\n\t\t\t\tvar cancelChanges = function()\r\n\t\t\t\t{\r\n\t\t\t\t\tdestroyEditor();\r\n\t\t\t\t};\r\n\t\t\t\tvar destroyEditor = function()\r\n\t\t\t\t{\r\n\t\t\t\t\teditor.destroy();\r\n\t\t\t\t\tself.__lastEditor = null;\r\n\t\t\t\t};\r\n\t\t\t\tvar position = this.__getPosition(cell);\r\n\t\t\t\tvar editorSetting = this.__config.editors[cell.cellIndex];\r\n\t\t\t\tvar editorFunction = (editorSetting.type) ? editorSetting.type.editor : editorSetting.customEditor;\r\n\t\t\t\tvar editorType = (editorSetting.type) ? editorSetting.type.type : \"outer\";\r\n\t\t\t\tvar setting = {container:cell,position:position,defaultValue:cell.innerText,commitChanges:commitChanges,cancelChanges:cancelChanges,validator:editorSetting.validator};\r\n\t\t\t\tvar editor = new editorFunction(setting,this.util);\r\n\t\t\t\teditor.__cell = cell;\r\n\t\t\t\teditor.__type = editorType;\r\n\t\t\t\teditor.__setting = editorSetting;\r\n\t\t\t\tthis.__lastEditor = editor;\r\n\t\t\t\tevent.preventDefault();\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__commitEditorChanges = function(editor)\r\n\t\t{\r\n\t\t\tvar self = this;\r\n\t\t\tvar destroyEditor = function()\r\n\t\t\t{\r\n\t\t\t\teditor.destroy();\r\n\t\t\t\teditor = null;\r\n\t\t\t\tself.__lastEditor = null;\r\n\t\t\t};\r\n\t\t\tvar cell = editor.__cell;\r\n\t\t\tvar editorType = editor.__type;\r\n\t\t\tvar editorSetting = editor.__setting;\r\n\t\t\tvar value = editor.getValue();\r\n\t\t\tvar objValidate = editor.validate();\r\n\t\t\tif(objValidate.isValid)\r\n\t\t\t{\r\n\t\t\t\tvar hasValueChanged = editor.hasValueChanged();\r\n\t\t\t\tdestroyEditor();\r\n\t\t\t\tif(hasValueChanged)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.setCellValue(cell,value);\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\talert(objValidate.message);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__refreshPosition = function(event)\r\n\t\t{\r\n\t\t\tif(this.__scrollableElement && this.__selectedCell)\r\n\t\t\t{\r\n\t\t\t\tvar cellRect = this.__selectedCell.getBoundingClientRect();\r\n\t\t\t\tvar newOffset = this.util.getPosition(this.__selectedCell,true);\r\n\t\t\t\t//vertical scroll logic\r\n\t\t\t \tvar cellTop = newOffset.top;\r\n\t\t\t var cellBottom = cellTop + cellRect.height;\r\n\t\t\t var scrollerHeight = this.__scrollableElement.clientHeight;\r\n\t\t\t var currentScrollTop = this.__scrollableElement.scrollTop;\r\n\t\t\t // scroll up\r\n\t\t\t if (cellTop < 0)\r\n\t\t\t {\r\n\t\t\t \tif(this.__selectedCell.parentNode.rowIndex < 2)\r\n\t\t\t \t{\r\n\t\t\t \t\tthis.__scrollableElement.scrollTop = 0;\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.__scrollableElement.scrollTop = currentScrollTop + cellTop;\t\r\n\t\t\t \t}\r\n\t\t\t }\r\n\t\t\t \t// scroll down\r\n\t\t\t else if (cellBottom > scrollerHeight)\r\n\t\t\t {\r\n\t\t\t var scrollAmount = cellBottom - scrollerHeight;\r\n\t\t\t this.__scrollableElement.scrollTop = currentScrollTop + scrollAmount;\r\n\t\t\t }\r\n\t\t\t \t//horizontal scroll logic\r\n\t\t\t var cellLeft = newOffset.left;\r\n\t\t\t var cellRight = cellLeft + cellRect.width;\r\n\t\t\t var scrollerWidth = this.__scrollableElement.clientWidth;\r\n\t\t\t var currentScrollLeft = this.__scrollableElement.scrollLeft;\r\n\t\t\t \t// scroll Left\r\n\t\t\t if (cellLeft < 0)\r\n\t\t\t {\r\n\t\t\t \tif(this.__selectedCell.cellIndex === 0)\r\n\t\t\t \t{\r\n\t\t\t \t\tthis.__scrollableElement.scrollLeft = 0;\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.__scrollableElement.scrollLeft = currentScrollLeft + cellLeft;\t\r\n\t\t\t \t}\r\n\t\t\t }\r\n\t\t\t \t// scroll Right\r\n\t\t\t else if (cellRight > scrollerWidth)\r\n\t\t\t {\r\n\t\t\t var scrollAmount = cellRight - scrollerWidth;\r\n\t\t\t this.__scrollableElement.scrollLeft = currentScrollLeft + scrollAmount;\r\n\t\t\t }\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__movingHandler = function(event)\r\n\t\t{\r\n\t\t\tevent = this.util.getEvent(event);\r\n\t\t\tvar target = this.util.getTarget(event);\r\n\t\t\t//var cell = this.__closestCell(target);\r\n\t\t\tvar cell = this.util.findParent(target,\"TD\");\r\n\t\t\tif(!cell)\r\n\t\t\t{\r\n\t\t\t\tvar cell = this.__getCellFromDragPosition(event);\r\n\t\t\t}\r\n\t if(cell)\r\n\t {\r\n\t \tthis.__selectCell(this.__getCellPosition(cell),true);\r\n\t \tthis.__refreshCells();\r\n\t \tthis.__repositionHandle(cell);\r\n\t }\r\n\t\t};\r\n\t\t\r\n\t\tthis.__repositionScrolls = function(event,isVertical,isHorizontal)\r\n\t\t{\r\n\t\t\tevent = this.util.getEvent(event);\r\n\t\t\tvar rect = this.__scrollableElement.getBoundingClientRect();\r\n\t\t\tif(isHorizontal)\r\n\t\t\t{\r\n\t\t var width = rect.width;\r\n\t\t var xPos = event.clientX - width / 2;\r\n\t\t this.__deltaX = xPos * 0.1;\r\n\t\t this.__scrollableElement.scrollLeft = this.__scrollableElement.scrollLeft + this.__deltaX;\r\n\t\t\t}\r\n\t\t\tif(isVertical)\r\n\t\t\t{\r\n\t\t\t\tvar height = rect.height;\r\n\t\t var yPos = event.clientY - height / 2;\r\n\t\t this.__deltaY = yPos * 0.1;\r\n\t\t this.__scrollableElement.scrollTop = this.__scrollableElement.scrollTop + this.__deltaY;\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__focus = function()\r\n\t\t{\r\n\t\t if(this.__table.ownerDocument.activeElement)\r\n\t\t {\r\n\t\t\t this.__table.ownerDocument.activeElement.blur();\r\n\t\t }\r\n\t\t this.__hasFocus = true;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__blur = function()\r\n\t\t{\r\n\t\t\tthis.__hasFocus = false;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__setFocus = function(enableFocus)\r\n\t\t{\r\n\t\t \tif(this.__hasFocus != enableFocus)\r\n\t\t \t{\r\n\t\t\t if(enableFocus)\r\n\t\t\t {\r\n\t\t\t \tthis.__focus();\r\n\t\t\t }\r\n\t\t\t else\r\n\t\t\t {\r\n\t\t\t \tthis.__blur();\r\n\t\t\t }\r\n\t\t\t return true;\r\n\t\t \t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__selectCell = function(position,isExpanding)\r\n\t\t{\r\n\t\t\t if(position)\r\n\t\t\t {\r\n\t\t\t\t this.__focus();\r\n\t\t\t\t var size = this.__getTotalSize();\r\n\t\t\t\t if(size && size.row && size.col)\r\n\t\t\t\t {\r\n\t\t\t\t\t if(isExpanding && typeof(isExpanding) == \"object\")\r\n\t\t\t\t\t {\r\n\t\t\t\t\t\t isExpanding = this.__getBoundCellPosition(isExpanding,size);\r\n\t\t\t\t\t }\r\n\t\t\t\t\t this.__setCurrentRange(this.__getBoundCellPosition(position,size),isExpanding);\r\n\t\t\t\t }\r\n\t\t\t }\r\n\t\t};\r\n\t\t\r\n\t\tthis.__refreshCells = function()\r\n\t\t{\r\n\t\t\tthis.__drawCellClass(this.__range.cursor);\r\n\t var position = {topLeft:this.__range.topLeft,bottomRight:this.__range.bottomRight};\r\n\t this.__drawAreaClass(position);\r\n\t\t};\r\n\t\t\r\n\t\tthis.__drawAreaClass = function(position)\r\n\t\t{\r\n\t\t\tvar self = this;\r\n\t\t\tvar cell = null;\r\n\t\t\tvar row = null;\r\n\t\t\tvar rowIndex = null;\r\n\t\t \tvar colIndex = null;\r\n\t\t \tvar processTable = function(arrElement,arrClass)\r\n\t\t\t{\r\n\t\t \t\tif(arrElement && arrElement.length > 0 && arrClass && arrClass.length > 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tfor(var count = 0;count < arrElement.length;count++)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfor(var innerCount = 0;innerCount < arrClass.length;innerCount++)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tself.util.removeStyleClass(arrElement[count],arrClass[innerCount]);\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\tvar addStyleClass = function(element,cssClass)\r\n\t\t\t{\r\n\t\t\t\tself.util.addStyleClass(element,cssClass);\r\n\t\t\t};\r\n\t\t\tvar areaClass = this.__config.areaClass;\r\n\t\t\tvar areaClassLeft = this.__config.areaClassLeft;\r\n\t\t\tvar areaClassRight = this.__config.areaClassRight;\r\n\t\t\tvar areaClassTop = this.__config.areaClassTop;\r\n\t\t\tvar areaClassBottom = this.__config.areaClassBottom;\r\n\t\t\tprocessTable(this.__table.querySelectorAll(\"tbody>tr>td.\" + areaClass),[areaClass,areaClassLeft,areaClassRight]);\r\n\t\t\tprocessTable(this.__table.querySelectorAll(\"colgroup>col.\" + areaClass),[areaClass,areaClassLeft,areaClassRight]);\r\n\t\t\tprocessTable(this.__table.querySelectorAll(\"tbody>tr.\" + areaClass),[areaClass,areaClassTop,areaClassBottom]);\r\n\t\t \tif(position && position.topLeft)\r\n\t\t \t{\r\n\t\t\t for(rowIndex = position.topLeft.row,row = this.__tblBody.rows[rowIndex];rowIndex <= position.bottomRight.row && row;rowIndex++,row= this.__tblBody.rows[rowIndex])\r\n\t\t\t {\r\n\t\t\t \taddStyleClass(row,areaClass);\r\n\t\t\t \tif(rowIndex == position.topLeft.row)\r\n\t\t\t \t{\r\n\t\t\t \t\taddStyleClass(row,areaClassTop);\r\n\t\t\t \t}\r\n\t\t\t \tif(rowIndex == position.bottomRight.row)\r\n\t\t\t \t{\r\n\t\t\t \t\taddStyleClass(row,areaClassBottom);\r\n\t\t\t \t}\r\n\t\t\t \tfor(colIndex = position.topLeft.col,cell = row.cells[colIndex];colIndex <= position.bottomRight.col && cell;colIndex++,cell = row.cells[colIndex])\r\n\t\t\t \t{\r\n\t\t\t \t\taddStyleClass(cell,areaClass);\r\n\t\t\t \tif(colIndex == position.topLeft.col)\r\n\t\t\t \t{\r\n\t\t\t \t\taddStyleClass(cell,areaClassLeft);\r\n\t\t\t \t}\r\n\t\t\t \tif(colIndex == position.bottomRight.col)\r\n\t\t\t \t{\r\n\t\t\t \t\taddStyleClass(cell,areaClassRight);\r\n\t\t\t \t}\r\n\t\t\t \t}\r\n\t\t\t }\r\n\t\t\t for(colIndex = position.topLeft.col;colIndex <= position.bottomRight.col;colIndex++)\r\n\t\t\t {\r\n\t\t\t \tcell = this.__getColGroup(colIndex);\r\n\t\t\t \taddStyleClass(cell,areaClass);\r\n\t\t\t \tif(colIndex == position.topLeft.col)\r\n\t\t \t{\r\n\t\t \t\taddStyleClass(cell,areaClassLeft);\r\n\t\t \t}\r\n\t\t \tif(colIndex == position.bottomRight.col)\r\n\t\t \t{\r\n\t\t \t\taddStyleClass(cell,areaClassRight);\r\n\t\t \t}\r\n\t\t\t }\r\n\t\t\t }\r\n\t\t};\r\n\t\t\r\n\t\tthis.__drawCellClass = function(position)\r\n\t\t{\r\n\t\t\tvar cellClass = this.__config.cellClass;\r\n\t\t\tvar self = this;\r\n\t\t\tvar processTable = function(arrElement)\r\n\t\t\t{\r\n\t\t\t\tif(arrElement && arrElement.length > 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tfor(var count = 0;count < arrElement.length;count++)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tself.util.removeStyleClass(arrElement[count],cellClass);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t};\r\n\t\t\tprocessTable(this.__table.querySelectorAll(\"tbody>tr>td.\" + cellClass));\r\n\t\t\tprocessTable(this.__table.querySelectorAll(\"colgroup>col.\" + cellClass));\r\n\t\t\tprocessTable(this.__table.querySelectorAll(\"tbody>tr.\" + cellClass));\r\n\t\t \tif(position)\r\n\t\t \t{\r\n\t\t \tvar cell = this.__getCell(position);\r\n\t\t \tif(cell)\r\n\t\t \t{\r\n\t\t \t\tthis.util.addStyleClass(cell,cellClass);\r\n\t\t \t\tthis.util.addStyleClass(cell.parentNode,cellClass);\r\n\t\t \t\tthis.__selectedCell = cell;\r\n\t\t \t}\r\n\t\t \tthis.util.addStyleClass(this.__getColGroup(position.col),cellClass);\r\n\t\t \t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__KeyMoveHandler = function(event)\r\n\t\t{\r\n\t\t\tevent = this.util.getEvent(event);\r\n\t\t \tif(event.ctrlKey || event.metaKey || event.altKey) \r\n\t\t \t{\r\n\t\t \t\treturn;\r\n\t\t \t}\r\n\t\t \tvar shiftKey = event.shiftKey;\r\n\t\t \tvar keyCode = this.util.KEYCODE;\r\n\t\t \tswitch(event.keyCode)\r\n\t\t \t{\r\n\t\t\t case keyCode.UP:\r\n\t\t\t this.__selectMove({row:-1,col:0},shiftKey);\r\n\t\t\t return true;\r\n\t\t\t case keyCode.DOWN:\r\n\t\t\t this.__selectMove({row:+1,col:0},shiftKey);\r\n\t\t\t return true;\r\n\t\t\t case keyCode.LEFT:\r\n\t\t\t this.__selectMove({row:0,col:-1},shiftKey);\r\n\t\t\t return true;\r\n\t\t\t case keyCode.RIGHT:\r\n\t\t\t this.__selectMove({row:0,col:+1},shiftKey);\r\n\t\t\t return true;\r\n\t\t\t case keyCode.TAB:\r\n\t\t\t this.__selectMove({row:0,col:shiftKey ? -1:+1});\r\n\t\t\t return true;\r\n\t\t\t case keyCode.ESC:\r\n\t\t\t\tthis.__deSelectCurrentRange();\r\n\t\t \treturn true;\r\n\t\t \t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__isKeyStrokeValid = function(target,validElement)\r\n\t\t{\r\n\t\t \twhile(target)\r\n\t\t \t{\r\n\t\t \tif(target.tagName == \"INPUT\" || target.tagName == \"TEXTAREA\" || target.contentEditable == \"true\" || target.tagName == \"SELECT\")\r\n\t\t \t{\r\n\t\t \t\treturn true;\t\r\n\t\t \t}\r\n\t\t \tif(target == validElement)\r\n\t\t \t{\r\n\t\t \t\treturn false;\r\n\t\t \t}\r\n\t\t \ttarget = target.parentNode;\r\n\t\t \t}\r\n\t\t \treturn false;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__selectMove = function(move,isExpanding)\r\n\t\t{\r\n\t\t \tvar cursor = this.__range.cursor || {};\r\n\t\t \tvar size = this.__getTotalSize();\r\n\t\t \tif(!size||!size.row||!size.col)\r\n\t\t \t{\r\n\t\t \treturn;\r\n\t\t \t}\r\n\t\t \tvar position = this.__getBoundCellPosition({row:cursor.row + (move.row || 0),col:cursor.col + (move.col||0)},size);\r\n\t\t \tif(isExpanding && typeof(isExpanding) == \"object\")\r\n\t\t \t{\r\n\t\t \t\tisExpanding = this.__getBoundCellPosition(isExpanding,size);\r\n\t\t \t}\r\n\t\t \tthis.__selectCell(position,isExpanding);\r\n\t\t};\r\n\t\t\r\n\t\tthis.__getColGroup = function(colIndex)\r\n\t\t{\r\n\t\t \tif(!this.__colgroup)\r\n\t\t \t{\r\n\t\t \tthis.__colgroup = this.__getElementsSnapshot(this.__table,\"colgroup\");\r\n\t\t \tif(this.__colgroup && this.__colgroup.length > 0)\r\n\t\t \t{\r\n\t\t \t\tthis.__colgroup = this.__colgroup[0];\r\n\t\t \t}\r\n\t\t \tif(!this.__colgroup || this.__colgroup.length === 0)\r\n\t\t \t{\r\n\t\t \t\tthis.__colgroup = this.__table.ownerDocument.createElement(\"colgroup\");\r\n\t\t \t\tthis.__table.appendChild(this.__colgroup);\r\n\t\t \t}\r\n\t\t \t}\r\n\t\t \twhile(!this.__colgroup.children[colIndex])\r\n\t\t \t{\r\n\t\t \tvar col = this.__table.ownerDocument.createElement(\"col\");\r\n\t\t \tthis.__colgroup.appendChild(col);\r\n\t\t \t}\r\n\t\t \treturn this.__colgroup.children[colIndex];\r\n\t\t};\r\n\t\t\r\n\t\tthis.__closestCell = function(target)\r\n\t\t{\r\n\t\t \twhile(target.parentNode)\r\n\t\t \t{\r\n\t\t \tif(target.parentNode.parentNode == this.__tblBody)\r\n\t\t \t{\r\n\t\t \t\treturn target;\t\r\n\t\t \t}\r\n\t\t \ttarget = target.parentNode;\r\n\t\t \t}\r\n\t\t \t\r\n\t\t \treturn null;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__getCellPosition = function(cell)\r\n\t\t{\r\n\t\t\treturn {row:cell.parentNode.sectionRowIndex,col:cell.cellIndex};\r\n\t\t};\r\n\t\t\r\n\t\tthis.__getTotalSize = function()\r\n\t\t{\r\n\t\t\t if(this.__tblBody)\r\n\t\t\t {\r\n\t\t\t var rowLength = this.__tblBody.rows.length;\r\n\t\t\t if(rowLength)\r\n\t\t\t {\r\n\t\t\t \treturn {row:rowLength,col:this.__tblBody.rows[0].cells.length};\r\n\t\t\t }\r\n\t\t\t }\r\n\t\t\t return null;\r\n\t\t};\r\n\t\t\t\r\n\t\tthis.__getBoundCellPosition = function(cellPosition,totalSize)\r\n\t\t{\r\n\t\t\t return {\r\n\t\t\t col: ((isNaN(cellPosition.col)|| cellPosition.col >= totalSize.col) ? 0 : ((cellPosition.col<0) ? totalSize.col - 1 : cellPosition.col)),\r\n\t\t\t row: ((isNaN(cellPosition.row)|| cellPosition.row >= totalSize.row) ? 0 : ((cellPosition.row<0) ? totalSize.row-1 : cellPosition.row))\r\n\t\t\t };\r\n\t\t};\r\n\t\t\r\n\t\tthis.__getCell = function(position)\r\n\t\t{\r\n\t\t \tif(position && this.__tblBody)\r\n\t\t \t{\r\n\t\t \t\tvar row = this.__tblBody.rows[position.row];\r\n\t\t\t\tif(row && row.cells)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn row.cells[position.col];\r\n\t\t\t\t}\r\n\t\t \t}\r\n\t\t \treturn null;\r\n\t\t};\r\n\t\t//range selection methods\r\n\t\tthis.__setCurrentRange = function(position,isExpanding)\r\n\t\t{\r\n\t\t \tthis.__range.cursor = this.__hasPositionChanged(this.__range.cursor,{row:position.row,col:position.col});\r\n\t\t \tif(typeof(isExpanding) == \"object\")\r\n\t\t \t{\r\n\t\t \t\tthis.__range.start = this.__hasPositionChanged(this.__range.start,{row:isExpanding.row,col:isExpanding.col});\r\n\t\t \t}\r\n\t\t \tif(!isExpanding || !this.__range.start)\r\n\t\t \t{\r\n\t\t \t\tthis.__range.start = this.__range.topLeft = this.__range.bottomRight = this.__range.cursor;\r\n\t\t \t}\r\n\t\t \telse\r\n\t\t \t{\r\n\t\t \t\tvar colToLeft = this.__config.enableFillHandle ? this.__range.start.col : Math.min(this.__range.start.col,this.__range.cursor.col);\r\n\t\t \t\tvar colBottomRight = this.__config.enableFillHandle ? this.__range.start.col : Math.max(this.__range.start.col,this.__range.cursor.col);\r\n\t\t \t\tthis.__range.topLeft = this.__hasPositionChanged(this.__range.topLeft,{row:Math.min(this.__range.start.row,this.__range.cursor.row),col:colToLeft});\r\n\t\t \t\tthis.__range.bottomRight = this.__hasPositionChanged(this.__range.bottomRight,{row:Math.max(this.__range.start.row,this.__range.cursor.row),col:colBottomRight});\r\n\t\t \t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__deSelectCurrentRange = function()\r\n\t\t{\r\n\t\t\tthis.__range = {};\r\n\t\t};\r\n\t\t\r\n\t\tthis.__hasPositionChanged = function(oldPosition,newPosition)\r\n\t\t{\r\n\t\t \treturn (!oldPosition || oldPosition.row != newPosition.row || oldPosition.col != newPosition.col) ? newPosition : oldPosition;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__isValidRange = function(position)\r\n\t\t{\r\n\t\t \treturn (this.__range.cursor && this.__range.topLeft.row <= position.row && position.row <= this.__range.bottomRight.row && this.__range.topLeft.col <= position.col && position.col <= this.__range.bottomRight.col);\r\n\t\t};\r\n\t\t//end of range selection methods\r\n\t\tthis.__getElementsSnapshot = function(element,type)\r\n\t\t{\r\n\t\t\ttry\r\n\t\t\t{\r\n\t\t\t\tvar xPathResult = element.ownerDocument.evaluate(type,element,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);\r\n\t\t\t\tvar length = xPathResult.snapshotLength;\r\n\t\t\t\tvar arrReturn = new Array(length);\r\n\t\t\t\tfor(var count = 0;count < length; count++)\r\n\t\t\t\t{\r\n\t\t\t\t\tarrReturn[count] = xPathResult.snapshotItem(count);\r\n\t\t\t\t}\r\n\t\t\t\treturn arrReturn;\r\n\t\t\t}\r\n\t\t\tcatch(error)\r\n\t\t\t{\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__formatDataForCopy = function(arrData)\r\n\t\t{\r\n\t\t \tif(arrData && arrData.length)\r\n\t\t \t{\r\n\t\t \tvar arrReturn = [];\r\n\t\t \tfor(var count = 0;count < arrData.length;count++)\r\n\t\t \t{\r\n\t\t \t\tvar arrInner = arrData[count];\r\n\t\t \t\tvar arrStr = [];\r\n\t\t \t\tfor(var innerCount = 0;innerCount < arrInner.length;innerCount++)\r\n\t\t \t\t{\r\n\t\t \t\tvar str = arrInner[innerCount];\r\n\t\t \t\tif(this.util.isString(str))\r\n\t\t \t\t{\r\n\t\t \t\t\tif(str.indexOf(\"\\n\") > -1)\r\n\t\t \t\t\t{\r\n\t\t \t\t\t\tarrStr.push('\"' + str.replace(/\"/g, '\"\"') + '\"');\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\tarrStr.push(str);\r\n\t\t \t\t\t}\r\n\t\t \t\t}\r\n\t\t \t\telse\r\n\t\t \t\t{\r\n\t\t \t\t\tarrStr.push(this.util.isUndefinedOrNull(str) ? \"\" : str);\r\n\t\t \t\t}\r\n\t\t \t\t}\r\n\t\t \t\tarrReturn.push(arrStr.join(\"\\t\"));\r\n\t\t \t}\r\n\t\t \treturn arrReturn.join(\"\\n\");\r\n\t\t \t}\r\n\t\t \treturn arrData;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__formatDataForPaste = function(data)\r\n\t\t{\r\n\t\t\tvar quotes = function(strData) \r\n\t\t\t{\r\n\t\t\t\treturn (strData.split('\"').length - 1) & 1;\r\n\t\t\t};\r\n\t\t\tif (this.util.isString(data)) \r\n\t\t\t{\r\n\t\t\t\tvar arrReturn = [];\r\n\t\t\t\tvar arrRows = data.split(\"\\n\");\r\n\t\t\t\tif (arrRows.length && arrRows[arrRows.length - 1] === \"\") \r\n\t\t\t\t{\r\n\t\t\t\t\tarrRows.pop();\r\n\t\t\t\t}\r\n\t\t\t\tvar arrRowData = []; \r\n\t\t\t\tvar isMultiline = false;\r\n\t\t\t\tfor (var rowCount = 0;rowCount