export declare const NSEditorCode = "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\n\r\n\t\t}\r\nvar NSEditor = (function()\r\n{\r\n\tfunction NSEditor(component,setting) \r\n\t{\r\n\t\tthis.__orignalTextArea = component;\r\n\t\tthis.__setting = setting;\r\n\t\t\r\n\t\tthis.__context = window;\r\n\t\t\r\n\t\tthis.editorUtil = null;\r\n\t\tthis.__config = null;\r\n\t\tthis.__selection = null;\r\n\t\tthis.__toolBar = null;\r\n\t\tthis.__execCommand = null;\r\n\t\tthis.__stack = null;\r\n\t\t\r\n\t\tthis.__divOuterContainer = null;\r\n\t\tthis.__divTabContainer = null;\r\n\t\tthis.__divBodyContainer = null;\r\n\t\tthis.__divFooterContainer = null;\r\n\t\tthis.__divFooterLeftContainer = null;\r\n\t\tthis.__divFooterRightContainer = null;\r\n\t\tthis.__divLineNumberContainer = null;\r\n\t\tthis.__divTextAreaContainer = null;\r\n\t\tthis.__compTextArea = null;\r\n\t\tthis.__divLineNumberWrapper = null;\r\n\t\tthis.__frameContentWindow = null;\r\n\t\tthis.__frameContentDoc = null;\r\n\t\tthis.__frameBody = null;\r\n\t\tthis.__txtSourceCode = null;\r\n\t\tthis.__iframePrint = null;\r\n\t\t\r\n\t\tthis.__textAreaScrollRef = null;\r\n\t\tthis.__textAreaResizeRef = null;\r\n\t\tthis.__textAreaKeyUpRef = null;\r\n\t\tthis.__textAreaKeyDownRef = null;\r\n\t\t\r\n\t\tthis.__textAreaObserver = null; \r\n\t\tthis.__orignalTextAreaObserver = null; \r\n\t\tthis.__timeOutInterval = null;\r\n\t\tthis.__lastTextAreaHeight = 0; \r\n\t\tthis.__lastTextAreaWidth = 0;\r\n\t\tthis.__paddingHorizontal = 0;\r\n\t\tthis.__browserDetail = null;\r\n\t\tthis.__dom = null;\r\n\t\tthis.__accessibleKeys = null;\r\n\t\tthis.__toolBarButton = null;\r\n\t\tthis.__objShortKey = {};\r\n\t\tthis.__isDisabled = false;\r\n\t\tthis.__isFrameDesignModeEnabled = false;\r\n\t\tthis.__isSourceMode = false;\r\n\t\tthis.__isInternalHTMLChange = false;\r\n\t\tthis.__hasRendered = false;\r\n\t\tthis.__renderedInterval = null;\r\n\t\tthis.__resizeInterval = null;\r\n\t\t//this.__defaultContent = \"<p class='nsEditorLineElement'><br></p>\";\r\n\t\tthis.__defaultContent = null;\r\n\t\t //queue up the functions not called as Creation Complete called later\r\n\t\tthis.__queueFunc = [];\r\n\t\t\r\n\t\tthis.__pluginsInstances = {};\r\n\t\tthis.__utilInstance = {};\r\n\t\t\r\n\t\tthis.__init();\r\n\t\t\r\n\t\tthis.base.__setBaseComponent.call(this,this.__divOuterContainer);\r\n\t};\r\n\tnsExtendPrototype(NSContainerBase,NSEditor);\r\n\tNSEditor.prototype.constructor = NSEditor;\r\n\t\r\n\tNSEditor.prototype.initializeComponent = function() \r\n\t{\r\n\t\tthis.base.initializeComponent.call(this);\r\n\t\tthis.__browserDetail = this.util.getBrowser();\r\n\t\tthis.__dom = this.util.getDomVariables();\r\n\t\tthis.__accessibleKeys = {ctrl:{str:\"ctrl\",isPressed:function(event,keyCode){\r\n\t\t\treturn (event.ctrlKey || event.metaKey || keyCode === 91 || keyCode === 92 || keyCode === 224);\r\n\t\t}},\r\n\t\tshift:{str:\"shift\",isPressed:function(event,keyCode){\r\n\t\t\treturn event.shiftKey;\r\n\t\t}},\r\n\t\talt:{str:\"alt\",isPressed:function(event,keyCode){\r\n\t\t\treturn event.altKey;\r\n\t\t}},\r\n\t\t}\r\n\t\t\r\n\t\tthis.__toolBarButton = {\"bold\":{html:\"<i class='ns-icon ns-editor-bold' aria-hidden='true'></i>\",tooltip:\"Bold\",tags: [\"b\", \"strong\"],css: {fontWeight: \"bold\"},shortKey:[\"ctrl+b\"],command:\"bold\",showAsMenu: true},\r\n\t\t\t\t   \"italic\":{html:\"<i class='ns-icon ns-editor-italics' aria-hidden='true'></i>\",tooltip:\"Italic\",tags: [\"i\", \"em\"],css: {fontStyle: \"italic\"},shortKey: [\"ctrl+i\"],command:\"italic\",showAsMenu: true},\r\n\t\t\t\t   \"underline\":{html:\"<i class='ns-icon ns-editor-underline' aria-hidden='true'></i>\",tooltip:\"Underline\",tags: [\"u\"],css: {textDecoration: \"underline\"},shortKey: [\"ctrl+u\"],command:\"underline\",showAsMenu: true},\r\n\t\t\t\t   \"strikeThrough\":{html:\"<i class='ns-icon ns-editor-strikethrough' aria-hidden='true'></i>\",tooltip:\"Strikethrough\",tags: [\"s\", \"strike\"],css: {textDecoration: \"line-through\"},shortKey: [\"ctrl+shift+s\"],command:\"strikeThrough\",showAsMenu: true},\r\n\t\t\t\t   \"justifyCenter\":{html:\"<i class='ns-icon ns-editor-align-center' aria-hidden='true'></i>\",tooltip:\"Justify Center\",css: {textAlign: \"center\"},command:\"justifyCenter\"},\r\n\t\t\t\t   \"justifyLeft\":{html:\"<i class='ns-icon ns-editor-align-left' aria-hidden='true'></i>\",tooltip:\"Justify Left\",css: {textAlign: \"left\"},command:\"justifyLeft\"},\r\n\t\t\t\t   \"justifyRight\":{html:\"<i class='ns-icon ns-editor-align-right' aria-hidden='true'></i>\",tooltip:\"Justify Right\",css: {textAlign: \"right\"},command:\"justifyRight\"},\r\n\t\t\t\t   \"justifyFull\":{html:\"<i class='ns-icon ns-editor-align-justify' aria-hidden='true'></i>\",tooltip:\"Justify Full\",tags: [\"s\", \"strike\"],css: {textAlign: \"justify\"},command:\"justifyFull\"},\r\n\t\t\t\t   \"subscript\":{html:\"<i class='ns-icon ns-editor-subscript' aria-hidden='true'></i>\",tooltip:\"Subscript\",tags: [\"sub\"],command:\"subscript\",showAsMenu: true},\r\n\t\t\t\t   \"superscript\":{html:\"<i class='ns-icon ns-editor-superscript' aria-hidden='true'></i>\",tooltip:\"Superscript\",tags: [\"sup\"],command:\"superscript\",showAsMenu: true},\r\n\t\t\t\t  \r\n\t\t\t\t   \"paragraph\":{html:\"<p>Normal</p>\",tooltip:\"Paragraph\",command: \"FormatBlock\",\r\n\t\t\t\t\t\t   \t\t    \"arguments\": (this.__browserDetail.isMSIE || this.__browserDetail.isSafari) ? \"<p>\" : \"p\",tags:[\"p\"]},\r\n\t\t\t\t   \"header1\":{html:\"<h1>Heading 1</h1>\",tooltip:\"Header 1\",\r\n\t\t\t\t\t   \t\t\t\t command: \"FormatBlock\",\r\n\t\t\t\t\t\t\t   \t\t \"arguments\": \"<h1>\",tags: [\"h1\"]},\r\n\t\t\t   \t   \"header2\":{html:\"<h2>Heading 2</h2>\",tooltip:\"Header 2\",\r\n\t\t\t   \t\t   \t\t  command: \"FormatBlock\",\r\n\t\t   \t\t\t\t \t  \"arguments\": \"<h2>\",tags: [\"h2\"]},\r\n\t\t\t\t   \"header3\":{html:\"<h3>Heading 3</h3>\",tooltip:\"Header 3\",\r\n\t\t\t\t\t   \t\t  command: \"FormatBlock\",\r\n\t\t\t\t\t\t\t  \"arguments\": \"<h3>\",tags: [\"h3\"]},\r\n\t\t\t\t   \"header4\":{html:\"<h4>Heading 4</h4>\",tooltip:\"Header 4\",\r\n\t\t\t\t\t   \t\t  command: \"FormatBlock\",\r\n\t\t\t   \t\t  \t\t \"arguments\": \"<h4>\",tags: [\"h4\"]},\r\n\t\t\t\t   \"orderedList\":{html:\"<i class='ns-icon ns-editor-ordered-list' aria-hidden='true'></i>\",tooltip:\"Ordered List\",command:\"insertorderedlist\",afterCommand:this.__orderedListHandler.bind(this),showAsMenu: true},\r\n\t\t\t\t   \"unorderedList\":{html:\"<i class='ns-icon ns-editor-unordered-list' aria-hidden='true'></i>\",tooltip:\"Unordered List\",command:\"insertunorderedlist\",afterCommand:this.__orderedListHandler.bind(this),showAsMenu: true},\r\n\t\t\t\t   \"undo\":{html:\"<i class='ns-icon ns-editor-undo' aria-hidden='true'></i>\",tooltip:\"Undo\",shortKey:[\"ctrl+z\"],command:\"undo\",showAsMenu: true},\r\n\t\t\t\t   \"redo\":{html:\"<i class='ns-icon ns-editor-redo' aria-hidden='true'></i>\",tooltip:\"Redo\",shortKey:[\"ctrl+y\"],command:\"redo\",showAsMenu: true},\r\n\t\t\t\t   \"outdent\":{html:\"<i class='ns-icon ns-editor-decrease-indent' aria-hidden='true'></i>\",tooltip:\"Decrease Indent\",command:\"outdent\",showAsMenu: true},\r\n\t\t\t\t   \"indent\":{html:\"<i class='ns-icon ns-editor-increase-indent' aria-hidden='true'></i>\",tooltip:\"Increase Indent\",command:\"indent\",showAsMenu: true},\r\n\t\t\t\t   \"viewSourceCode\":{html:\"<i class='ns-icon ns-editor-source' aria-hidden='true'></i>\",tooltip:\"View Source Code\",click: this.__viewSourceCodeHandler.bind(this),showAsMenu: true},\r\n\t\t\t\t   \"clear\":{html:\"<i class='ns-icon ns-editor-new-doc' aria-hidden='true'></i>\",tooltip:\"Empty Document\",click: this.__emptyDocHandler.bind(this),showAsMenu: true},\r\n\t\t\t\t   \"print\":{html:\"<i class='ns-icon ns-editor-print' aria-hidden='true'></i>\",tooltip:\"Print\",click: this.__printHandler.bind(this),showAsMenu: true},\r\n\t\t\t\t   \"preview\":{html:\"<i class='ns-icon ns-editor-preview' aria-hidden='true'></i>\",tooltip:\"Preview\",click: this.__previewHandler.bind(this),showAsMenu: true},\r\n\t\t\t\t   \"pageBreakForPrinting\":{html:\"<i class='ns-icon ns-editor-bookmark' aria-hidden='true'></i>\",tooltip:\"Insert Page Break for Printing\",click: this.__pageBreakForPrintingHandler.bind(this),showAsMenu: true},\r\n\t\t\t\t   \"horizontalRule\":{html:\"<i class='ns-icon ns-editor-minus' aria-hidden='true'></i>\",tooltip:\"Insert Horizontal Line\",command:\"insertHorizontalRule\",tags:[\"hr\"],showAsMenu: true},\r\n\t\t\t\t   \"fontFamily\":{html:\"<i class='ns-icon ns-editor-font' aria-hidden='true'></i>\",tooltip:\"Font Family\",showAsMenu: true,\r\n\t\t\t   \t\t\tisDropdown:true,\r\n\t\t\t   \t\t\tdataSource:[{value:\"Arial\",html:\"<span style=\\\"font-family: Arial\\\">Arial</span>\",tooltip:\"Arial\",command:\"fontName\",\"arguments\":\"Arial\"},\r\n\t\t\t   \t\t\t            {value:\"Arial Black\",html:\"<span style=\\\"font-family: Arial Black\\\">Arial Black</span>\",tooltip:\"Arial Black\",command:\"fontName\",\"arguments\":\"Arial Black\"},\r\n\t\t\t   \t\t\t            {value:\"Courier\",html:\"<span style=\\\"font-family: Courier\\\">Courier</span>\",tooltip:\"Courier\",command:\"fontName\",\"arguments\":\"Courier\"},\r\n\t\t\t   \t\t\t            {value:\"Courier New\",html:\"<span style=\\\"font-family: Courier New\\\">Courier New</span>\",tooltip:\"Courier New\",command:\"fontName\",\"arguments\":\"Courier New\"},\r\n\t\t\t   \t\t\t            {value:\"Comic Sans MS\",html:\"<span style=\\\"font-family: Comic Sans MS\\\">Comic Sans MS</span>\",tooltip:\"Comic Sans MS\",command:\"fontName\",\"arguments\":\"Comic Sans MS\"},\r\n\t\t\t   \t\t\t            {value:\"Courier\",html:\"<span style=\\\"font-family: Courier\\\">Courier</span>\",tooltip:\"Courier\",command:\"fontName\",\"arguments\":\"Courier\"},\r\n\t\t\t   \t\t\t            {value:\"Georgia\",html:\"<span style=\\\"font-family: Georgia\\\">Georgia</span>\",tooltip:\"Georgia\",command:\"fontName\",\"arguments\":\"Georgia\"},\r\n\t\t\t   \t\t\t            {value:\"Impact\",html:\"<span style=\\\"font-family: Impact\\\">Impact</span>\",tooltip:\"Impact\",command:\"fontName\",\"arguments\":\"Impact\"},\r\n\t\t\t   \t\t\t            {value:\"Lucida Grande\",html:\"<span style=\\\"font-family: Lucida Grande\\\">Lucida Grande</span>\",tooltip:\"Lucida Grande\",command:\"fontName\",\"arguments\":\"Lucida Grande\"},\r\n\t\t\t   \t\t\t            {value:\"Lucida Sans\",html:\"<span style=\\\"font-family: Lucida Sans\\\">Lucida Sans</span>\",tooltip:\"Lucida Sans\",command:\"fontName\",\"arguments\":\"Lucida Sans\"},\r\n\t\t\t   \t\t\t            {value:\"Serif\",html:\"<span style=\\\"font-family: Serif\\\">Serif</span>\",tooltip:\"Serif\",command:\"fontName\",\"arguments\":\"Serif\"},\r\n\t\t\t   \t\t\t            {value:\"Sans\",html:\"<span style=\\\"font-family: Sans\\\">Sans</span>\",tooltip:\"Sans\",command:\"fontName\",\"arguments\":\"Sans\"},\r\n\t\t\t   \t\t\t            {value:\"Tahoma\",html:\"<span style=\\\"font-family: Tahoma\\\">Tahoma</span>\",tooltip:\"Tahoma\",command:\"fontName\",\"arguments\":\"Tahoma\"},\r\n\t\t\t   \t\t\t            {value:\"Times\",html:\"<span style=\\\"font-family: Times\\\">Times</span>\",tooltip:\"Times\",command:\"fontName\",\"arguments\":\"Times\"},\r\n\t\t\t   \t\t\t            {value:\"Times New Roman\",html:\"<span style=\\\"font-family: Times New Roman\\\">Times New Roman</span>\",tooltip:\"Times New Roman\",command:\"fontName\",\"arguments\":\"Times New Roman\"},\r\n\t\t\t   \t\t\t            {value:\"Verdana\",html:\"<span style=\\\"font-family: Verdana\\\">Verdana</span>\",tooltip:\"Verdana\",command:\"fontName\",\"arguments\":\"Verdana\"}]},\r\n\t\t\t\t   \"fontSize\":{html:\"<i class='ns-icon ns-editor-font-size' aria-hidden='true'></i>\",tooltip:\"Font Size\",showAsMenu: true,\r\n\t\t\t\t\t   \t\t    isDropdown:true,dataSource:[]},\r\n\t\t\t\t   \"paragraphFormat\":{html:\"<i class='ns-icon ns-editor-paragraph' aria-hidden='true'></i>\",tooltip:\"Paragraph Format\",showAsMenu: true,\r\n\t\t\t\t\t   \t\t\tisDropdown:true,\r\n\t\t\t\t\t   \t\t\tdataSource:[{value:\"paragraph\",htmlKey:\"paragraph\"},\r\n\t\t\t\t\t   \t\t\t            {value:\"header1\",htmlKey:\"header1\"},\r\n\t\t\t\t\t   \t\t\t            {value:\"header2\",htmlKey:\"header2\"},\r\n\t\t\t\t\t   \t\t\t            {value:\"header3\",htmlKey:\"header3\"},\r\n\t\t\t\t\t   \t\t\t            {value:\"header4\",htmlKey:\"header4\"}]},\r\n \t\t\t       \"align\":{html:\"<i class='ns-icon ns-editor-align-left' aria-hidden='true'></i>\",tooltip:\"Align\",showAsMenu: true,\r\n\t \t\t\t    \t  \t\tisDropdown:true,\r\n\t \t\t\t    \t  \t\tdataSource:[{value:\"justifyCenter\",htmlKey:\"justifyCenter\"},\r\n\t \t\t\t    \t  \t\t            {value:\"justifyLeft\",htmlKey:\"justifyLeft\"},\r\n\t \t\t\t    \t  \t\t            {value:\"justifyRight\",htmlKey:\"justifyRight\"},\r\n\t \t\t\t    \t  \t\t            {value:\"justifyFull\",htmlKey:\"justifyFull\"}]},\r\n\t \t\t       \"color\":{html:\"<i class='ns-icon ns-editor-font-color' aria-hidden='true'></i>\",tooltip:\"Font Color\",showAsMenu: true,\r\n\t \t\t\t\t\t\t   isDropdown:true,dataSource:[]},\r\n\t \t\t\t   \"backgroundColor\":{html:\"<i class='ns-icon ns-editor-background-color' aria-hidden='true'></i>\",tooltip:\"Background Color\",showAsMenu: true,\r\n\t\t \t\t\t\t\t   isDropdown:true,dataSource:[]},\r\n\t\t\t\t };\r\n\t\t//the browser doesnot allow font size > 7\r\n\t\tvar arrFontSize = [{label:\"xx-large\",style:\"xx-large\",value:7},\r\n\t\t                   {label:\"x-large\",style:\"x-large\",value:6},\r\n\t\t                   {label:\"large\",style:\"large\",value:5},\r\n\t\t                   {label:\"medium\",style:\"medium\",value:4},\r\n\t\t                   {label:\"small\",style:\"small\",value:3},\r\n\t\t                   {label:\"x-small\",style:\"x-small\",value:2},\r\n\t\t                   {label:\"xx-small\",style:\"xx-small\",value:1}];\r\n\t\tvar fontDataSource = [];\r\n\t\tfor(var count = 0;count < arrFontSize.length;count++)\r\n\t\t{\r\n\t\t\tvar item = arrFontSize[count];\r\n\t\t\tfontDataSource.push({value:item.label,html:\"<span style=\\\"font-size: \" + item.style + \"\\\">\" + item.label + \"</span>\",command:\"fontsize\",\"arguments\":item.value});\r\n\t\t}\r\n\t\tthis.__toolBarButton[\"fontSize\"].dataSource = fontDataSource;\r\n\t\tvar arrForeColor = [{label:\"#000000\",style:\"#000000\",value:\"#000000\"},\r\n\t\t                    {label:\"#0000FF\",style:\"#0000FF\",value:\"#0000FF\"},\r\n\t\t\t\t\t\t\t{label:\"#30AD23\",style:\"#30AD23\",value:\"#30AD23\"},\r\n\t\t\t\t\t\t\t{label:\"#FF7F00\",style:\"#FF7F00\",value:\"#FF7F00\"},\r\n\t\t\t\t\t\t\t{label:\"#FF0000\",style:\"#FF0000\",value:\"#FF0000\"},\r\n\t\t\t\t\t\t\t{label:\"#FFFF00\",style:\"#FFFF00\",value:\"#FFFF00\"},\r\n\t\t\t\t\t\t\t{label:\"#FFFFFF\",style:\"#FFFFFF\",value:\"#FFFFFF\"}];\r\n\t\tvar foreColorDataSource = [];\r\n\t\tfor(var count = 0;count < arrForeColor.length;count++)\r\n\t\t{\r\n\t\t\tvar item = arrForeColor[count];\r\n\t\t\tforeColorDataSource.push({value:item.label,html:\"<span style=\\\"color: \" + item.style + \"\\\">\" + item.label + \"</span>\",command:\"forecolor\",\"arguments\":item.value});\r\n\t\t}\r\n\t\tthis.__toolBarButton[\"color\"].dataSource = foreColorDataSource;\r\n\t\tvar arrBackColor = [{label:\"#000000\",style:\"#000000\",value:\"#000000\"},\r\n\t\t                    {label:\"#0000FF\",style:\"#0000FF\",value:\"#0000FF\"},\r\n\t\t\t\t\t\t\t{label:\"#30AD23\",style:\"#30AD23\",value:\"#30AD23\"},\r\n\t\t\t\t\t\t\t{label:\"#FF7F00\",style:\"#FF7F00\",value:\"#FF7F00\"},\r\n\t\t\t\t\t\t\t{label:\"#FF0000\",style:\"#FF0000\",value:\"#FF0000\"},\r\n\t\t\t\t\t\t\t{label:\"#FFFF00\",style:\"#FFFF00\",value:\"#FFFF00\"},\r\n\t\t\t\t\t\t\t{label:\"#FFFFFF\",style:\"#FFFFFF\",value:\"#FFFFFF\"}];\r\n\t\tvar backColorDataSource = [];\r\n\t\tfor(var count = 0;count < arrBackColor.length;count++)\r\n\t\t{\r\n\t\t\tvar item = arrBackColor[count];\r\n\t\t\tbackColorDataSource.push({value:item.label,html:\"<span style=\\\"color: \" + item.style + \"\\\">\" + item.label + \"</span>\",command:\"backcolor\",\"arguments\":item.value});\r\n\t\t}\r\n\t\tthis.__toolBarButton[\"backgroundColor\"].dataSource = backColorDataSource;\r\n\t\tthis.__initializeModules();\r\n\t\tthis.__initializePlugins();\r\n\t\tthis.__setSetting();\r\n\t\tthis.__initDefault();\r\n\t\tthis.__initializeTools();\r\n\t\tthis.__callInitializeInPluggin();\r\n\t\tthis.__createComponent();\r\n\t\tthis.attachResizeListener();\r\n\t};\r\n\t\r\n\tNSEditor.prototype.setComponentProperties = function() \r\n\t{\r\n\t\tthis.base.setComponentProperties.call(this);\r\n\t};\r\n\t\r\n\tNSEditor.prototype.propertyChange = function(attrName, oldVal, newVal, setProperty)\r\n\t{\r\n\t\tvar attributeName = attrName.toLowerCase();\r\n\t\tthis.base.propertyChange.call(this,attrName, oldVal, newVal, setProperty);\r\n\t};\r\n\t\r\n\tNSEditor.prototype.removeComponent = function() \r\n\t{\r\n\t\tthis.base.removeComponent.call(this);\r\n\t\tthis.util.removeStyleClass(this.__dom.doc.body,\"nsEditorPresent\");\r\n\t\tthis.__callDestroyInPluggin();\r\n\t\tclearTimeout(this.__resizeInterval);\r\n\t\tvar listenerComponent = this.__getListenerComponent();\r\n\t\tif(this.__textAreaScrollRef)\r\n\t\t{\r\n\t\t\tvar element = this.__getScrollableComponent();\r\n\t\t\tthis.util.removeEvent(element,\"scroll\",this.__textAreaScrollRef);\r\n\t\t\tthis.__textAreaScrollRef = null;\r\n\t\t}\r\n\t\tif(this.__textAreaResizeRef)\r\n\t\t{\r\n\t\t\tthis.util.removeEvent(listenerComponent,\"resize\",this.__textAreaResizeRef);\r\n\t\t\tthis.__textAreaResizeRef = null;\r\n\t\t}\r\n\t\tif(this.__textAreaKeyUpRef)\r\n\t\t{\r\n\t\t\tthis.util.removeEvent(listenerComponent,\"keyup\",this.__textAreaKeyUpRef);\r\n\t\t\tthis.__textAreaKeyUpRef = null;\r\n\t\t}\r\n\t\tif(this.__textAreaKeyDownRef)\r\n\t\t{\r\n\t\t\tthis.util.removeEvent(listenerComponent,\"keydown\",this.__textAreaKeyDownRef);\r\n\t\t\tthis.__textAreaKeyDownRef = null;\r\n\t\t}\r\n\t\tthis.__toolBar.destroy();\r\n\t\tif(this.__orignalTextAreaObserver)\r\n\t\t{\r\n\t\t\tthis.__orignalTextAreaObserver.disconnect();\r\n\t\t\tthis.__orignalTextAreaObserver = null;\r\n\t\t}\r\n\t\tif(this.__textAreaObserver)\r\n\t\t{\r\n\t\t\tthis.__textAreaObserver.disconnect();\r\n\t\t\tthis.__textAreaObserver = null;\r\n\t\t}\r\n\t\tif(this.__divOuterContainer)\r\n\t\t{\r\n\t\t\tif(this.__divOuterContainer.parentNode)\r\n\t\t\t{\r\n\t\t\t\tthis.__divOuterContainer.parentNode.removeChild(this.__divOuterContainer);\r\n\t\t\t}\r\n\t\t\tthis.__divOuterContainer = null;\r\n\t\t}\r\n\t\tif(this.__orignalTextArea)\r\n\t\t{\r\n\t\t\tthis.util.removeStyleClass(this.__orignalTextArea,\"nsEditorTextAreaHidden\");\r\n\t\t}\r\n\t\tif(this.__iframePrint)\r\n\t\t{\r\n\t\t\tif(this.__iframePrint.parentNode)\r\n\t\t\t{\r\n\t\t\t\tthis.__iframePrint.parentNode.removeChild(this.__iframePrint);\r\n\t\t\t}\r\n\t\t\tthis.__iframePrint = null;\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSEditor.prototype.componentResized = function(event) \r\n\t{\r\n\t\tvar baseMeasurement = this.__baseComponent.getBoundingClientRect();\r\n\t\tif(!this.__lastBaseMeasurement || this.__lastBaseMeasurement.height !== baseMeasurement.height || this.__lastBaseMeasurement.width !== baseMeasurement.width)\r\n\t\t{\r\n\t\t\tevent = this.util.getEvent(event);\r\n\t\t\tclearTimeout(this.__resizeInterval);\r\n\t\t\tvar self = this;\r\n\t\t\tthis.__resizeInterval = setTimeout(function(){\r\n\t\t\t\tself.__dispatchInternalEvent(\"resize\",{orignalEvent:event},{orignalEvent:event});\r\n\t\t\t\tself.__callResizedInPluggin([event]);\r\n\t\t\t\tself.base.componentResized.call(self,event);\r\n\t\t\t}, 250);\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSEditor.prototype.registerPlugin = function(name,pluggin) \r\n\t{\r\n\t\tif(name && pluggin)\r\n\t\t{\r\n\t\t\tif(!NSEditor.__plugins)\r\n\t\t\t{\r\n\t\t\t\tNSEditor.__plugins = {};\r\n\t\t\t}\r\n\t\t\tif(!NSEditor.__plugins[name])\r\n\t\t\t{\r\n\t\t\t\tNSEditor.__plugins[name] = pluggin;\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSEditor.prototype.registerUtil = function(name,util) \r\n\t{\r\n\t\tif(name && util)\r\n\t\t{\r\n\t\t\tif(!NSEditor.__util)\r\n\t\t\t{\r\n\t\t\t\tNSEditor.__util = {};\r\n\t\t\t}\r\n\t\t\tif(!NSEditor.__util[name])\r\n\t\t\t{\r\n\t\t\t\tNSEditor.__util[name] = util;\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\t\r\n\t//if setting[\"enableLineNumber\"] is true then the components for line Number is created and then \r\n\t// with toggleLineNumber function the Line Number visibility can be toggled\r\n\tNSEditor.prototype.toggleLineNumber = function() \r\n\t{\r\n\t\tthis.__config[\"enableLineNumber\"] = !this.__config[\"enableLineNumber\"];\r\n\t\tthis.__setLineNumberVisibility(this.__config[\"enableLineNumber\"]);\r\n\t};\r\n\t\r\n\tNSEditor.prototype.setDisabled = function(isDisabled) \r\n\t{\r\n\t\tthis.__isDisabled = isDisabled;\r\n\t};\r\n\t\r\n\tNSEditor.prototype.getDisabled = function() \r\n\t{\r\n\t\treturn this.__isDisabled;\r\n\t};\r\n\t\r\n\tNSEditor.prototype.getText = function() \r\n\t{\r\n\t\tvar text = this.__getTextFromTextArea();\r\n\t\treturn (text ? text.replace(/(\\r\\n|\\n|\\r)/gm, \"\") : \"\");\r\n\t};\r\n\t\r\n\tNSEditor.prototype.setText = function(text) \r\n\t{\r\n\t\tthis.__setTextIntoTextArea(text);\r\n\t};\r\n\t\r\n\tNSEditor.prototype.getHtml = function() \r\n\t{\r\n\t\treturn this.__getHtmlFromTextArea();\r\n\t};\r\n\t\r\n\tNSEditor.prototype.setHtml = function(html) \r\n\t{\r\n\t\tthis.__setHtmlIntoTextArea(html);\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__initDefault = function()\r\n\t{\r\n\t\t//item in autoSuggestTriggers will be {keyCode: 32, ctrlKey: true,shiftKey: false, preventDefault: true}\r\n\t\tif(!this.__config[\"autoSuggestTriggers\"])\r\n\t\t{\r\n\t\t\tthis.__config[\"autoSuggestTriggers\"] = [];\r\n\t\t}\r\n\t\tif(!this.__config[\"mode\"])\r\n\t\t{\r\n\t\t\tthis.__config[\"mode\"] = NSEditor.MODE_TEXTAREA;\r\n\t\t}\r\n\t\tthis.__setDefaultContent();\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__setDefaultContent = function()\r\n\t{\r\n\t\tthis.__defaultContent = this.__getDefaultContent();\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__getDefaultContent = function(asHtml)\r\n\t{\r\n\t\tasHtml = this.util.isUndefinedOrNull(asHtml) ? true : Boolean.parse(asHtml);\r\n\t\tvar defaultElement = this.util.createElement(this.__config[\"enterElement\"],null,\"nsEditorLineElement\");\r\n\t\tif(defaultElement)\r\n\t\t{\r\n\t\t\tdefaultElement.innerHTML = \"<br>\"; \r\n\t\t}\r\n\t\telse \r\n\t\t{\r\n\t\t\tthis.util.throwNSError(\"NSEditor\",\"Enter a valid enterElement property\");\r\n\t\t}\r\n\t\treturn asHtml ? (defaultElement ? defaultElement.outerHTML : null) : defaultElement;\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__setSetting = function()\r\n\t{\r\n\t\tif(!this.__setting)\r\n\t\t{\r\n\t\t\tthis.__setting = {};\r\n\t\t}\r\n\t\tif(!this.__config)\r\n\t\t{\r\n\t\t\tthis.__config = {};\r\n\t\t}\r\n\t\tvar setting = this.__setting;\r\n\t\tif(setting)\r\n\t\t{\r\n\t\t\tif(setting.hasOwnProperty(\"context\"))\r\n\t\t\t{\r\n\t\t\t\tthis.__context = setting[\"context\"];\r\n\t\t\t}\r\n\t\t\tthis.__config = {\r\n\t\t\t\t\tenableToolBar: this.util.isUndefinedOrNull(this.__setting[\"enableToolBar\"]) ? true : Boolean.parse(this.__setting[\"enableToolBar\"]),\r\n\t\t\t\t\ttoolBarButton: this.__setting[\"toolBarButton\"],\r\n\t\t\t\t\tenableReadOnly: Boolean.parse(this.__setting[\"enableReadOnly\"]),\r\n\t\t\t\t\twidth: this.__setting[\"width\"] || \"auto\",\r\n\t\t\t\t    height: this.__setting[\"height\"] || \"auto\",\r\n\t\t\t\t    minWidth: this.__setting[\"minWidth\"] || 200,\r\n\t\t\t\t\tminHeight: this.__setting[\"minHeight\"] || 200,\r\n\t\t\t\t\tmaxWidth: this.__setting[\"maxWidth\"] || \"100%\",\r\n\t\t\t\t\tmaxHeight: this.__setting[\"maxHeight\"] || \"100%\",\r\n\t\t\t\t    theme: this.__setting[\"theme\"] || \"White\",\r\n\t\t\t\t    //if this property is true then if bold is selected then in dom we use <b> or <strong> tag etc\r\n\t\t\t\t    //else we use style to do the same\r\n\t\t\t\t    enableTagsForProps: Boolean.parse(this.__setting[\"enableTagsForProps\"]),\r\n\t\t\t\t\tenableSpellCheck: this.util.isUndefinedOrNull(this.__setting[\"enableSpellCheck\"]) ? true : Boolean.parse(this.__setting[\"enableSpellCheck\"]),\r\n\t\t\t\t\tenableTabBar: Boolean.parse(this.__setting[\"enableTabBar\"]),\r\n\t\t\t\t\tenableLineNumber: Boolean.parse(this.__setting[\"enableLineNumber\"]),\r\n\t\t\t\t\tenableToolBarActive: Boolean.parse(this.__setting[\"enableToolBarActive\"]),\r\n\t\t\t\t\tenableAutoSuggest: Boolean.parse(this.__setting[\"enableAutoSuggest\"]),\r\n\t\t\t\t\tautoSuggestTriggers: this.__setting[\"autoSuggestTriggers\"],\r\n\t\t\t\t\tmode: this.__setting[\"mode\"],\r\n\t\t\t\t\tplaceholder: this.__setting[\"placeholder\"],\r\n\t\t\t\t\tenterElement: this.__setting[\"enterElement\"] || \"p\",// should ideally be <p> or <div> as others can create problems\r\n\t\t\t\t\tmaxCharCount: this.util.isUndefinedOrNull(this.__setting[\"maxCharCount\"]) ? null : parseInt(this.__setting[\"maxCharCount\"]),\r\n\t\t\t\t\tcharCounterType: this.__setting[\"charCounterType\"] || \"char\", //char, byte, byte-html\r\n\t\t\t\t\tenableStickyToolbar: this.util.isUndefinedOrNull(this.__setting[\"enableStickyToolbar\"]) ? true : Boolean.parse(this.__setting[\"enableStickyToolbar\"]),\r\n\t\t\t\t\tenableStickyToolbarForMobile: this.util.isUndefinedOrNull(this.__setting[\"enableStickyToolbarForMobile\"]) ? true : Boolean.parse(this.__setting[\"enableStickyToolbarForMobile\"]),\r\n\t\t\t\t\tpromptBoxCallback: this.__setting[\"promptBoxCallback\"] ? this.util.getFunction(this.__setting[\"promptBoxCallback\"]) : null,\r\n\t\t\t};\r\n\t\t}\r\n\t\tthis.__callSetSettingsInPluggin();\r\n\t\tif(this.__config.enableToolBar && (!this.__config.toolBarButton || this.__config.toolBarButton.length == 0))\r\n\t\t{\r\n\t\t\tthis.__config.toolBarButton = [];\r\n\t\t\tfor(var key in this.__toolBarButton)\r\n\t\t\t{\r\n\t\t\t\tif(this.__toolBarButton[key].showAsMenu)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__config.toolBarButton.push(key);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__init = function()\r\n\t{\r\n\t\tthis.__divOuterContainer = document.createElement(\"div\");\r\n\t\tthis.__divOuterContainer.setAttribute(\"class\",\"nsEditor nsEditorOuterContainer\");\r\n\t\tif(this.__orignalTextArea && this.__orignalTextArea.parentNode)\r\n\t\t{\r\n\t\t\tif(this.__orignalTextArea.nextSibling)\r\n\t\t\t{\r\n\t\t\t\tthis.__orignalTextArea.parentNode.insertBefore(this.__divOuterContainer, this.__orignalTextArea.nextSibling);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthis.__orignalTextArea.parentNode.appendChild(this.__divOuterContainer);\r\n\t\t\t}\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tdocument.body.appendChild(this.__divOuterContainer);\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__initializeTools = function()\r\n\t{\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__createComponent = function()\r\n\t{\r\n\t\tthis.util.addStyleClass(this.__dom.doc.body,\"nsEditorPresent\");\r\n\t\tthis.__createFixedComp();\r\n\t\tthis.__toolBar.createToolBar();\r\n\t\tthis.__createTabBar();\r\n\t\tthis.__createBody();\r\n\t\tthis.__createFooter();\r\n\t\tthis.__createPlaceHolder();\r\n\t\tif(this.__isModeTextArea())\r\n\t\t{\r\n\t\t\tthis.__initTextArea();\r\n\t\t}\r\n\t\t/*if(this.__isModeTextArea())\r\n\t\t{\r\n\t\t\tthis.__callTextAreaFunc();\r\n\t\t}*/\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__renderComplete = function()\r\n\t{\r\n\t\tvar self = this;\r\n\t\tvar callback = function()\r\n\t\t{\r\n\t\t\tif(self.__hasRendered)\r\n\t\t\t{\r\n\t\t\t\tif(self.__renderedInterval)\r\n\t\t\t\t{\r\n\t\t\t\t\tclearInterval(self.__renderedInterval);\r\n\t\t\t\t\tself.__renderedInterval = null;\r\n\t\t\t\t}\r\n\t\t\t\tif(self.__queueFunc && self.__queueFunc.length > 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tfor(var count = self.__queueFunc.length - 1;count > -1;count--)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tself.__queueFunc[count]();\r\n\t\t\t\t\t\tself.__queueFunc.splice(count, 1);\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\tthis.__renderedInterval = setInterval(callback, 300);\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__callTextAreaFunc = function()\r\n\t{\r\n\t\tthis.__callComponentsInitializedInPluggin();\r\n\t\tthis.__setStyles();\r\n\t\tthis.__renderComplete();\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__resizeCallback = function(forciblyCalc,delayPeriod)\r\n\t{\r\n\t\tvar self = this;\r\n\t\tvar callback = function()\r\n\t\t{\r\n\t\t\tself.__setBodyStyle(forciblyCalc);\r\n\t\t\tself.__resizeIframe();\r\n\t\t\tself.__drawLineNumbers(1);\r\n\t\t};\r\n\t\tif(!delayPeriod)\r\n\t\t{\r\n\t\t\tdelayPeriod = 0;\r\n\t\t}\r\n\t\tsetTimeout(callback,delayPeriod);\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__setStyles = function(delayPeriod)\r\n\t{\r\n\t\tvar self = this;\r\n\t\tvar callback = function()\r\n\t\t{\r\n\t\t\tvar css = {};\r\n\t\t\tcss.minWidth = self.__config.minWidth;\r\n\t\t\tcss.minHeight = self.__config.minHeight;\r\n\t\t\tvar maxWidth = self.__config.maxWidth;\r\n\t\t\tcss.maxWidth = maxWidth;\r\n\t\t\tself.util.css(self.__divOuterContainer,css);\r\n\t\t\tself.__width(self.__config.width);\r\n\t\t\tself.__height(self.__config.height);\r\n\t\t\t\r\n\t\t\t//delay while rendering as the toolBox is taking time to get its height\r\n\t\t\tself.__setBodyStyle(false,false);\r\n\t\t};\r\n\t\tif(!delayPeriod)\r\n\t\t{\r\n\t\t\tdelayPeriod = 0;\r\n\t\t}\r\n\t\tsetTimeout(callback,delayPeriod);\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__setBodyStyle = function(forciblyCalc,isDelay)\r\n\t{\r\n\t\tvar self = this;\r\n\t\tvar callback = function()\r\n\t\t{\r\n\t\t\tvar setHeight = function(value)\r\n\t\t\t{\r\n\t\t\t\tvar arrCon = [self.__divLineNumberContainer,self.__divTextAreaContainer,self.__compTextArea];//self.__getIFrameBody()\r\n\t\t\t\tfor(var count = 0;count < arrCon.length;count++)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar con = arrCon[count];\r\n\t\t\t\t\tif(con)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tself.util.css(con,\"height\",value);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t};\r\n\t\t\tforciblyCalc = Boolean.parse(forciblyCalc);\r\n\t\t\tvar height = \"auto\";\r\n\t\t\tif(self.__config.height == \"auto\" && !forciblyCalc)\r\n\t\t\t{\r\n\t\t\t\tsetHeight(\"auto\");\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tvar totalHeight = self.__divOuterContainer.offsetHeight;\r\n\t\t\t\tvar nonEditorHeight = self.__getNonEditorHeight();\r\n\t\t\t\theight = totalHeight - nonEditorHeight;\r\n\t\t\t\tif(forciblyCalc)\r\n\t\t\t\t{\r\n\t\t\t\t\tsetHeight(\"\");\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tself.__heightBody(height);\r\n\t\t\tself.__setBodyMinHeight();\r\n\t\t};\r\n\t\tif(isDelay)\r\n\t\t{\r\n\t\t\tsetTimeout(callback,100);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tcallback();\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__setBodyMinHeight = function()\r\n\t{\r\n\t\tvar nonEditorHeight = this.__getNonEditorHeight();\r\n\t\tvar minHeight = this.__config.minHeight - nonEditorHeight;\r\n\t\tthis.util.css(this.__divBodyContainer,\"minHeight\",minHeight);\r\n\t\tvar arrCon = [this.__divLineNumberContainer,this.__divTextAreaContainer,this.__compTextArea,this.__getIFrameBody()];//\r\n\t\tfor(var count = 0;count < arrCon.length;count++)\r\n\t\t{\r\n\t\t\tvar con = arrCon[count];\r\n\t\t\tif(con)\r\n\t\t\t{\r\n\t\t\t\tthis.util.css(con,\"minHeight\",minHeight - 2);\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis.__hasRendered = true;\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__getNonEditorHeight = function()\r\n\t{\r\n\t\tvar totalHeight = 0;\r\n\t\tif(this.__toolBar.__divToolBarContainer)\r\n\t\t{\r\n\t\t\ttotalHeight += this.__toolBar.__divToolBarContainer.offsetHeight;\r\n\t\t}\r\n\t\tif(this.__divTabContainer)\r\n\t\t{\r\n\t\t\ttotalHeight += this.__divTabContainer.offsetHeight;\r\n\t\t}\r\n\t\tif(this.__divFooterContainer)\r\n\t\t{\r\n\t\t\ttotalHeight += this.__divFooterContainer.offsetHeight;\r\n\t\t}\r\n\t\treturn totalHeight;\r\n\t};\r\n\t\r\n\t\r\n\t\r\n\tNSEditor.prototype.__createTabBar = function()\r\n\t{\r\n\t\tthis.__divTabContainer = this.util.createDiv(this.getID() + \"tabcontainer\",\"nsEditorTabContainer\");\r\n\t\tthis.__divOuterContainer.appendChild(this.__divTabContainer);\r\n\t\tif(this.__config[\"enableTabBar\"])\r\n\t\t{\r\n\t\t\t//this.__createToolBarComponents();\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis.__handleVisibilityOfComponent(this.__divTabContainer,\"enableTabBar\");\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__createBody = function()\r\n\t{\r\n\t\tthis.__divBodyContainer = this.util.createDiv(this.getID() + \"bodycontainer\",\"nsEditorBodyContainer\");\r\n\t\tthis.__divLineNumberContainer = this.util.createDiv(this.getID() + \"linenumbercontainer\",\"nsEditorLineNumberContainer\");\r\n\t\tthis.__divTextAreaContainer = this.util.createDiv(this.getID() + \"textareacontainer\",\"nsEditorTextAreaContainer\");\r\n\t\tthis.__divBodyContainer.appendChild(this.__divLineNumberContainer);\r\n\t\tthis.__divBodyContainer.appendChild(this.__divTextAreaContainer);\r\n\t\tthis.__divOuterContainer.appendChild(this.__divBodyContainer);\r\n\t\tthis.__compTextArea = this.__createTextArea();\r\n\t\tthis.__divTextAreaContainer.appendChild(this.__compTextArea);\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__createTextArea = function()\r\n\t{\r\n\t\tvar divTextArea = null;\r\n\t\tvar content = \"\";\r\n\t\tif(this.__isModeTextArea())\r\n\t\t{\r\n\t\t\t//do not add class here as it will get overriden from if orignalTextArea has class\r\n\t\t\tdivTextArea = this.util.createDiv(this.getID() + \"textArea\",null);\r\n\t\t\tif(!this.__config.enableReadOnly)\r\n\t\t\t{\r\n\t\t\t\tdivTextArea.setAttribute(\"contenteditable\",true);\r\n\t\t\t\tdivTextArea.setAttribute(\"spellcheck\",this.__config.enableSpellCheck);\r\n\t\t\t}\r\n\t\t\tif(this.__orignalTextArea)\r\n\t\t\t{\r\n\t\t\t\tif(this.__orignalTextArea.value.length > 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tcontent = this.__orignalTextArea.value;\r\n\t\t\t\t}\r\n\t\t\t\tvar arrAttributes = [\"tabIndex\"];\r\n\t\t\t\tvar arrNewAttributes = [\"tabIndex\"];\r\n\t\t\t\tfor(var count = 0;count < arrAttributes.length;count++)\r\n\t\t\t\t{\r\n\t\t\t\t\tif(this.__orignalTextArea.getAttribute(arrAttributes[count]))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tdivTextArea.setAttribute(arrNewAttributes[count],this.__orignalTextArea.getAttribute(arrAttributes[count]));\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse if(this.__config.defaultValue && this.__config.defaultValue.length > 0)\r\n\t\t\t{\r\n\t\t\t\tdivTextArea.appendChild(this.__dom.doc.createTextNode(this.__config.defaultValue));\r\n\t\t\t}\r\n\t\t\tthis.util.addStyleClass(divTextArea,\"nsEditorTextArea\");\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tdivTextArea = this.util.createElement(\"iframe\",this.getID() + \"textArea\",\"nsEditorTextAreaIFrame\");\r\n\t\t\tif(this.__context.location.protocol === \"https:\")\r\n\t\t\t{\r\n\t\t\t\tdivTextArea.setAttribute(\"src\",\"about:blank\");\r\n\t\t\t}\r\n\t\t\tdivTextArea.setAttribute(\"frameborder\",\"0\");\r\n\t\t\tdivTextArea.setAttribute(\"allowtransparency\",\"true\");\r\n\t\t\tdivTextArea.setAttribute(\"tabindex\",\"-1\");\r\n\t\t\tif(this.__orignalTextArea)\r\n\t\t\t{\r\n\t\t\t\t/*if(this.__orignalTextArea.getAttribute(\"tabindex\"))\r\n\t\t\t\t{\r\n\t\t\t\t\tdivTextArea.setAttribute(\"tabindex\",this.__orignalTextArea.getAttribute(\"tabindex\"));\r\n\t\t\t\t}*/\r\n\t\t\t\tif(this.__orignalTextArea.value.length > 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tcontent = this.__orignalTextArea.value;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tvar styleHtml = \"html\\r\\n\" + \r\n\t\t\t\t\t\"\t\t{\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\tmargin:0px;\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\theight:auto;\\r\\n\" + \r\n\t\t\t\t\t\"\t\t}\\r\\n\" + \r\n\t\t\t\t\t\"\t\t.nsEditorBody\\r\\n\" + \r\n\t\t\t\t\t\"\t\t{\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\theight:auto;\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\tbackground:transparent;\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\tcolor:#000000;\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\tposition:relative;\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\tz-index: 2;\\r\\n\" +\r\n\t\t\t\t\t\"\t\t\t-webkit-user-select:auto;\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\tmargin:0px;\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\tmin-height:50px;\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\tpadding: 5px;\\r\\n\" +\r\n\t\t\t\t\t\"\t\t\toverflow: auto;\\r\\n\" +\r\n\t\t\t\t\t\"\t\t}\\r\\n\" + \r\n\t\t\t\t\t\"\t\t.nsEditorBody:after\\r\\n\" + \r\n\t\t\t\t\t\"\t\t{\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\tcontent:\\'\\';\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\tdisplay:block;\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\tclear:both;\\r\\n\" + \r\n\t\t\t\t\t\"\t\t}\\r\\n\" + \r\n\t\t\t\t\t\"\t\t.nsEditorBody::-moz-selection\\r\\n\" + \r\n\t\t\t\t\t\"\t\t{\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\tbackground:#b5d6fd;\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\tcolor:#000;\\r\\n\" + \r\n\t\t\t\t\t\"\t\t}\\r\\n\" + \r\n\t\t\t\t\t\"\t\t.nsEditorBody::selection\\r\\n\" + \r\n\t\t\t\t\t\"\t\t{\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\tbackground:#b5d6fd;\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\tcolor:#000;\\r\\n\" + \r\n\t\t\t\t\t\"\t\t}\\r\\n\" + \r\n\t\t\t\t\t\"\t\t.nsEditorBody.nsEditorBodyWithLineNumber\\r\\n\" + \r\n\t\t\t\t\t\"\t\t{\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\tpadding: 0px;\\r\\n\" +\r\n\t\t\t\t\t\"\t\t\tpadding-top: 5px;\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\tpadding-right: 5px;\\r\\n\" + \t\t\t\r\n\t\t\t\t\t\"\t\t}\\r\\n\" + \r\n\t\t\t\t\t\"\t\t.nsEditorBody.nsEditorBodyWithLineNumber .nsEditorLineElement\\r\\n\" + \r\n\t\t\t\t\t\"\t\t{\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\tmargin:0;\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\tfont-size: 12px;\\r\\n\" +\r\n\t\t\t\t\t\"\t\t\tline-height: 15px !important;\\r\\n\" +\r\n\t\t\t\t\t\"\t\t}\\r\\n\" + \r\n\t\t\t\t\t\"\t\t.nsEditorPageBreak\\r\\n\" + \r\n\t\t\t\t\t\"\t\t{\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\tclear: both !important;\\r\\n\" + \r\n\t\t\t\t\t\"    \t\twidth: 100% !important;\\r\\n\" + \r\n\t\t\t\t\t\"    \t\tborder-top: #999 1px dotted !important;\\r\\n\" + \r\n\t\t\t\t\t\"    \t\tborder-bottom: #999 1px dotted !important;\\r\\n\" + \r\n\t\t\t\t\t\"    \t\tpadding: 0 !important;\\r\\n\" + \r\n\t\t\t\t\t\"    \t\theight: 7px !important;\\r\\n\" + \r\n\t\t\t\t\t\"    \t\tcursor: default !important;\\r\\n\" + \r\n\t\t\t\t\t\"\t\t}\";\r\n\t\t\tvar arrStyle = this.__callAddStyleIFrameInPluggin(style);\r\n\t\t\tif(arrStyle && arrStyle.length > 0)\r\n\t\t\t{\r\n\t\t\t\tfor(var count = 0;count < arrStyle.length;count++)\r\n\t\t\t\t{\r\n\t\t\t\t\tstyleHtml += arrStyle[count].value;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tvar arrStyle = this.__dom.doc.querySelectorAll(\"style\");\r\n\t\t\tif(arrStyle && arrStyle.length > 0)\r\n\t\t\t{\r\n\t\t\t\tfor(var count= 0;count < arrStyle.length; count++)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar style = arrStyle[count].cloneNode(true);\r\n\t\t\t\t\tstyleHtml += \"\\n\" + style.outerHTML;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tvar arrLink = this.__dom.doc.querySelectorAll(\"link\");\r\n\t\t\tif(arrLink && arrLink.length > 0)\r\n\t\t\t{\r\n\t\t\t\tfor(var count= 0;count < arrLink.length; count++)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar link = this.__dom.doc.createElement(\"link\");\r\n\t\t\t\t\tlink.rel = arrLink[count].rel;\r\n\t\t\t\t\tlink.href = arrLink[count].href;\r\n\t\t\t\t\tlink.type = \"text/css\";\r\n\t\t\t\t\tlink.media = \"all\";\r\n\t\t\t\t\tstyleHtml += \"\\n\" + link.outerHTML;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tvar html = \"<html><head><style>\" + styleHtml + \"</style></head><body class=\\\"nsEditorBody\" + (this.__config[\"enableLineNumber\"] ? \" nsEditorBodyWithLineNumber\" : \"\") + \"\\\" contenteditable=\\\" \" + !this.__config.enableReadOnly + \"\\\" aria-disabled=\\\"false\\\" spellcheck=\\\"\" + this.__config.enableSpellCheck +\"\\\" dir=\\\"auto\\\">\" + content + \"</body></html>\";\r\n\t\t\tthis.__enableIFrameDesignMode(divTextArea,html);\r\n\t\t}\r\n\t\tif(!content && this.__config.defaultValue && this.__config.defaultValue.length > 0)\r\n\t\t{\r\n\t\t\tcontent = this.__config.defaultValue;\r\n\t\t}\r\n\t\t//for Mozilla showing cursor\r\n\t\tif(content)\r\n\t\t{\r\n\t\t\tcontent = this.__getWrappedContent(content);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tcontent = this.__defaultContent;\r\n\t\t}\r\n\t\tthis.__config.defaultValue = content;\r\n\t\tif(this.__orignalTextArea)\r\n\t\t{\r\n\t\t\tthis.util.addStyleClass(this.__orignalTextArea,\"nsEditorTextAreaHidden\");\r\n\t\t\tif(!this.__config[\"placeholder\"] && this.__orignalTextArea.getAttribute(\"placeholder\"))\r\n\t\t\t{\r\n\t\t\t\tthis.__config[\"placeholder\"] = this.__orignalTextArea.getAttribute(\"placeholder\");\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis.util.addStyleClass(divTextArea,\"nsEditorTextAreaGeneric\");\r\n\t\t\r\n\t\treturn divTextArea;\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__initTextArea = function()\r\n\t{\r\n\t\tvar listenerComponent = this.__getListenerComponent();\r\n\t\tvar clickListener = this.__isModeTextArea() ? this.__compTextArea : this.__frameContentDoc;\r\n\t\tvar body = this.__isModeTextArea() ? this.__compTextArea : this.__getIFrameBody();\r\n\t\tvar self = this;\r\n\t\t\r\n\t\tvar genericListerener = function(event)\r\n\t\t{\r\n\t\t\tevent = self.util.getEvent(event);\r\n\t\t\tif(event.type == \"blur\")\r\n\t\t\t{\r\n\t\t\t\tif(!self.getDisabled())\r\n\t\t\t\t{\r\n\t\t\t\t\tself.__selection.saveSelection();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tvar element = event.target;\r\n\t\t\tvar parentElement = element.parentNode;\r\n\t\t\tvar item = {orignalEvent:event,element: element,parentElement: parentElement};\r\n\t\t\tself.__dispatchInternalEvent(event.type,item,item);\r\n\t\t};\r\n\t\t\r\n\t\tvar eventListener = function(event){\r\n\t\t\tevent = self.util.getEvent(event);\r\n\t\t\t//var target = self.util.getTarget(event);\r\n\t\t\tself.__selection.saveSelection();\r\n\t\t\t//self.__updateToolbar(target);\r\n\t\t};\r\n\t\tvar pasteListener = function(event)\r\n\t\t{\r\n\t\t\tevent = self.util.getEvent(event);\r\n\t\t\tswitch(event.type)\r\n\t\t\t{\r\n\t\t\t\tcase \"beforepaste\":\r\n\t\t\t\t\tself.__dispatchInternalEvent(\"beforepaste\",{orignalEvent:event},{orignalEvent:event});\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase \"paste\":\r\n\t\t\t\t\tvar content = self.__getPastedHTML(event);\r\n\t\t\t\t\tif(!content)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcontent = {};\r\n\t\t\t\t\t}\r\n\t\t\t\t\tcontent.orignalEvent = event;\r\n\t\t\t\t\tself.__dispatchInternalEvent(\"paste\",content,content);\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tif(this.__config.defaultValue)\r\n\t\t{\r\n\t\t\tbody.innerHTML = this.__config.defaultValue;\r\n\t\t}\r\n\t\tvar nonClickEvents = \"keydown keyup keypress mousedown mouseup mousemove copy cut dragstart drop dragover touchstart touchend touchmove focus blur\";\r\n\t\tvar clickEvents = \"selectionchange selectionstart dblclick click paste\";\r\n\t\tthis.util.addEvent(listenerComponent,nonClickEvents,genericListerener);\r\n\t\tthis.util.addEvent(clickListener,clickEvents,genericListerener);\r\n\t\t//this.util.addEvent(listenerComponent,\"keydown\",this.__textAreaKeyDownHandler.bind(this));\r\n\t\t//this.util.addEvent(listenerComponent,\"keyup mouseup mouseout focusout\",eventListener);\r\n\t\tthis.util.addEvent(clickListener,\"beforepaste paste\",pasteListener);\r\n\t\tthis.util.addEvent(clickListener,\"click\",this.__textAreaClickHandler.bind(this));\r\n\t\t/*if(!this.__isModeTextArea())\r\n\t\t{\r\n\t\t\tthis.__callTextAreaFunc();\r\n\t\t}*/\r\n\t\tthis.__createLineNumberComponents();\r\n\t\tthis.__callTextAreaFunc();\r\n\t\tthis.__dispatchInternalEvent(\"textAreaInitialized\");\r\n\t\tthis.__textAreaObserver = new MutationObserver(this.__textAreaChangeHandler.bind(this));\r\n\t\tvar observerConfig = {attributes:false,childList:true,characterData:true,subtree:true};\r\n\t\tthis.__textAreaObserver.observe(body, observerConfig);\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__enableIFrameDesignMode = function(iframe,html)\r\n\t{\r\n\t\tif(iframe && !this.__isFrameDesignModeEnabled)\r\n\t\t{\r\n\t\t\tthis.__frameContentWindow = this.__getIFrameContentWindow(iframe);\r\n\t\t\ttry \r\n\t\t\t{\r\n\t\t\t\tthis.__frameContentDoc = this.__frameContentWindow.document;\r\n\t\t\t\tthis.__frameContentDoc.open();\r\n\t\t\t\tthis.__frameContentDoc.write(html);\r\n\t\t\t\tthis.__frameContentDoc.close();\r\n            } \r\n\t\t\tcatch (error) \r\n\t\t\t{\r\n                //console.debug(error);\r\n            }\r\n            if (this.__dom.doc.contentEditable) \r\n\t\t\t{\r\n            \tthis.__frameContentDoc.designMode = \"On\";\r\n            \tthis.__isFrameDesignModeEnabled = true;\r\n            } \r\n\t\t\telse if (this.__dom.doc.designMode !== null) \r\n\t\t\t{\r\n                try \r\n\t\t\t\t{\r\n                \tthis.__frameContentDoc.designMode = \"on\";\r\n                \tthis.__isFrameDesignModeEnabled = true;\r\n                } \r\n\t\t\t\tcatch (error) \r\n\t\t\t\t{\r\n                    //console.debug(error);\r\n                }\r\n            }\r\n            if(this.__isFrameDesignModeEnabled)\r\n            {\r\n            \tthis.__setIframeStyle();\r\n            \tthis.__initTextArea();\r\n            \tthis.__dispatchInternalEvent(\"iframeInitialized\");\r\n            }\r\n            var self = this;\r\n            this.__timeOutInterval = setTimeout(function () \r\n\t\t    {\r\n            \tself.__timeOutInterval = null;\r\n            \tself.__enableIFrameDesignMode.call(self,iframe,html);\r\n\t\t    }, 500);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tclearTimeout(this.__timeOutInterval);\r\n\t\t\tthis.__timeOutInterval = null;\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__setIframeStyle = function()\r\n\t{\r\n\t\tif(this.__config.height == \"auto\")\r\n\t\t{\r\n\t\t\tvar doc = this.__getDocument();\r\n\t\t\tif(doc.documentElement)\r\n\t\t\t{\r\n\t\t\t\tdoc.documentElement.style.overflowY = \"hidden\";\r\n\t\t\t}\r\n\t\t\t//this.util.addEvent(doc,\"readystatechange DOMContentLoaded\",this.__resizeIframe.bind(this));\r\n\t\t\tthis.__listenInternalEvent(\"change\", this.__resizeIframe.bind(this));\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__resizeIframe = function()\r\n\t{\r\n\t\tif(!this.__isModeTextArea() && this.__config.height == \"auto\")\r\n\t\t{\r\n\t\t\tvar iframe = this.__compTextArea;\r\n\t\t\tvar body = this.__getIFrameBody();\r\n\t\t\tif(iframe && body)\r\n\t\t\t{\r\n\t\t\t\tthis.util.css(iframe,\"height\",body.offsetHeight);\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__createLineNumberComponents = function()\r\n\t{\r\n\t\tvar listenerComponent = this.__getListenerComponent();\r\n\t\tif(this.__config[\"enableLineNumber\"])\r\n\t\t{\r\n\t\t\tthis.util.addStyleClass(this.__divOuterContainer,\"nsEditorWithLineNumber\");\r\n\t\t\t//var textWidth = this.__width();\r\n\t\t\t//var baseMeasurement = this.__compTextArea.getBoundingClientRect();\r\n\t\t\tthis.__divLineNumberWrapper = this.util.createDiv(this.getID() + \"linenumberwrapper\",\"nsEditorLineNumberWrapper\");\r\n\t\t\tthis.__divLineNumberContainer.appendChild(this.__divLineNumberWrapper);\r\n\t\t\tthis.__queueFunc.splice(0, 0, this.__drawLineNumbers.bind(this,1));\r\n\t\t\tthis.__paddingHorizontal = parseInt(this.util.getStyleValue(this.__divOuterContainer,\"border-left-width\",false)) +\r\n\t\t\t\t\t\t\t\t\tparseInt(this.util.getStyleValue(this.__divOuterContainer,\"border-right-width\",false)) + \r\n\t\t\t\t\t\t\t\t\tparseInt(this.util.getStyleValue(this.__divOuterContainer,\"padding-left\",false)) + \r\n\t\t\t\t\t\t\t\t\tparseInt(this.util.getStyleValue(this.__divOuterContainer,\"padding-right\",false));\r\n\t\t\t//this.__setWidth(textWidth - this.__paddingHorizontal);\r\n\t\t\t//this.__lastTextAreaHeight = this.__compTextArea.offsetHeight; \r\n\t\t\t//this.__lastTextAreaWidth = this.__compTextArea.offsetWidth;\r\n\t\t\tif(!this.__textAreaScrollRef)\r\n\t\t\t{\r\n\t\t\t\tthis.__textAreaScrollRef = this.__textAreaScrollHandler.bind(this);\r\n\t\t\t\tvar element = this.__getScrollableComponent();\r\n\t\t\t\tthis.util.addEvent(element,\"scroll\",this.__textAreaScrollRef);\r\n\t\t\t}\r\n\t\t\tif(!this.__textAreaResizeRef)\r\n\t\t\t{\r\n\t\t\t\tthis.__textAreaResizeRef = this.__textAreaResizeHandler.bind(this);\r\n\t\t\t\tthis.util.addEvent(listenerComponent,\"resize\",this.__textAreaResizeRef);\r\n\t\t\t}\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tif(this.__divLineNumberContainer && this.__divLineNumberContainer.parentElement)\r\n\t\t\t{\r\n\t\t\t\tthis.__divLineNumberContainer.parentElement.removeChild(this.__divLineNumberContainer);\r\n\t\t\t\tthis.__divLineNumberContainer = null;\r\n\t\t\t}\r\n\t\t\tthis.util.removeStyleClass(this.__divOuterContainer,\"nsEditorWithLineNumber\");\r\n\t\t}\r\n\t\tif(this.__config[\"enableAutoSuggest\"])\r\n\t\t{\r\n\t\t\tif(!this.__textAreaKeyUpRef)\r\n\t\t\t{\r\n\t\t\t\tthis.__textAreaKeyUpRef = this.__textAreaKeyUpHandler.bind(this);\r\n\t\t\t\tthis.util.addEvent(listenerComponent,\"keyup\",this.__textAreaKeyUpRef);\r\n\t\t\t}\r\n\t\t\tif(!this.__textAreaKeyDownRef)\r\n\t\t\t{\r\n\t\t\t\tthis.__textAreaKeyDownRef = this.__textAreaKeyDownHandler.bind(this);\r\n\t\t\t\tthis.util.addEvent(listenerComponent,\"keydown\",this.__textAreaKeyDownRef);\r\n\t\t\t}\r\n\t\t}\r\n\t\t//observer to watch if orignalTextArea has some style changed\r\n\t\tif(!this.__orignalTextAreaObserver && this.__orignalTextArea)\r\n\t\t{\r\n\t\t\tthis.__orignalTextAreaObserver = new MutationObserver(this.__orignalTextAreaStyleChangeHandler.bind(this));\r\n\t\t\tthis.__orignalTextAreaObserver.observe(this.__orignalTextArea, {attributes:true,attributeFilter:[\"style\"]});\r\n\t\t}\r\n\t\tthis.__setLineNumberVisibility(this.__config[\"enableLineNumber\"]);\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__createFooter = function()\r\n\t{\r\n\t\tthis.__divFooterContainer = this.util.createDiv(this.getID() + \"footercontainer\",\"nsEditorFooterContainer\");\r\n\t\tthis.__divFooterLeftContainer = this.util.createDiv(this.getID() + \"footerleftcontainer\",\"nsEditorFooterLeftContainer\");\r\n\t\tthis.__divFooterContainer.appendChild(this.__divFooterLeftContainer);\r\n\t\tthis.__divFooterRightContainer = this.util.createDiv(this.getID() + \"footerrightcontainer\",\"nsEditorFooterRightContainer\");\r\n\t\tthis.__divFooterContainer.appendChild(this.__divFooterRightContainer);\r\n\t\tthis.__divOuterContainer.appendChild(this.__divFooterContainer);\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__textAreaKeyDownHandler = function(event)\r\n\t{\r\n\t\tevent = this.util.getEvent(event);\r\n\t\tif(!this.getDisabled())\r\n\t\t{\r\n\t\t\tif (event.keyCode === this.util.KEYCODE.BACKSPACE) \r\n\t\t\t{ \r\n\t\t\t\tif (this.__isTextAreaBlank()) \r\n\t\t\t\t{ \r\n\t\t\t\t\tevent.stopPropagation(); // prevent remove single empty tag\r\n\t\t\t\t\tevent.preventDefault();\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\tvar keyCode = event.keyCode;\r\n\t\t\t\tvar arrAccessKey = [];\r\n\t\t\t\tvar strKey = \"\";\r\n\t\t\t\tfor(var key in this.__accessibleKeys) \r\n\t\t\t\t{\r\n\t\t\t\t\tif(this.__accessibleKeys[key].isPressed(event,keyCode))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tarrAccessKey.push(this.__accessibleKeys[key]);\r\n\t\t\t\t\t\tstrKey += \"+\" + this.__accessibleKeys[key].str;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tif(arrAccessKey.length)\r\n\t\t\t\t{\r\n\t\t\t\t\tif(strKey && strKey.length > 1)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tstrKey = strKey.substring(1);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tstrKey += \"+\" + String.fromCharCode(keyCode);\r\n\t\t\t\t\tvar keyItem = this.__objShortKey[strKey.toLowerCase()];\r\n\t\t\t\t\tif(keyItem)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.__toolBar.__toolBarButtonClickHandler(keyItem.item,keyItem.key,event);\r\n\t\t\t\t\t\tthis.editorUtil.stopEvent(event);\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};\r\n\t\r\n\tNSEditor.prototype.__textAreaKeyUpHandler = function(event)\r\n\t{\r\n\t\t /*if (decls.isVisible())\r\n         {\r\n             decls.setFilter(getFilterText());\r\n         }*/\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__textAreaClickHandler = function(event)\r\n\t{\r\n\t\tvar target = this.util.getTarget(event);\r\n\t\tthis.__toolBar.updateToolbar(target);\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__textAreaScrollHandler = function(event)\r\n\t{\r\n\t\tif(!this.__timeOutInterval)\r\n\t\t{\r\n\t\t\tvar lineNumberHeight = 15;\r\n\t\t\tvar self = this;\r\n\t\t\tthis.__timeOutInterval = setTimeout( function() \r\n\t\t\t{\r\n\t\t\t\tvar listenerComponent = self.__getScrollComponent();\r\n\t\t\t\tvar scrollTop = listenerComponent.scrollTop;\r\n\t\t\t\tvar firstLine = Math.floor((scrollTop / lineNumberHeight) + 1);\r\n\t\t\t\tvar remainingScroll = (scrollTop / lineNumberHeight) % 1;\r\n\r\n\t\t\t\tself.__drawLineNumbers(firstLine);\r\n\t\t\t\tself.__divLineNumberWrapper.style.marginTop = (-1 * (remainingScroll * lineNumberHeight)) + \"px\";\r\n\t\t\t\tself.__timeOutInterval = null;\r\n\t\t\t}, 150);\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__textAreaResizeHandler = function(event)\r\n\t{\r\n\t\t\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__orignalTextAreaStyleChangeHandler = function(arrMutation)\r\n\t{\r\n\t\tfor(var count = 0;count < arrMutation.length;count++)\r\n\t\t{\r\n\t\t\tvar mutation = arrMutation[count];\r\n\t\t\tif (mutation.type == \"attributes\") \r\n\t        {\r\n\t        \t\r\n\t        }\r\n\t\t\t\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__textAreaChangeHandler= function(arrMutation)\r\n\t{\r\n\t\tif(!this.__isInternalHTMLChange)\r\n\t\t{\r\n\t\t\t//this.__setDefaultTag();\r\n\t\t\tthis.__dispatchInternalEvent(\"change\");\r\n\t\t\t//this.__resizeIframe();\r\n\t\t}\r\n\t\tfor(var count = 0;count < arrMutation.length;count++)\r\n\t\t{\r\n\t\t\tvar mutation = arrMutation[count];\r\n\t\t\t//if child is added\r\n\t\t\tif (mutation.type === 'childList') \r\n\t\t\t{\r\n\t\t\t\t//if height is auto\r\n\t\t\t\tif(this.__config.height == \"auto\" && this.__divLineNumberContainer)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__drawLineNumbers(1);\r\n\t\t\t\t}\r\n\t        }\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__drawLineNumbers = function(fromLine)\r\n\t{\r\n\t\tif(this.__divLineNumberWrapper)\r\n\t\t{\r\n\t\t\tthis.util.removeAllChildren(this.__divLineNumberWrapper);\r\n\t\t\tthis.arrLinesElement = [];\r\n\t\t\tvar comp = this.__getScrollComponent();\r\n\t\t\tvar measurement = comp.getBoundingClientRect();\r\n\t\t\tvar containerHeight = measurement.height;\r\n\t\t\twhile((this.__divLineNumberWrapper.offsetHeight - containerHeight) <= 0)\r\n\t\t\t{\r\n\t\t\t\tvar divLineNumber = this.util.createDiv(this.getID() + \"linenumber\",\"nsEditorLineNumber\");\r\n\t\t\t\tdivLineNumber.appendChild(this.__dom.doc.createTextNode(fromLine));\r\n\t\t\t\tthis.__divLineNumberWrapper.appendChild(divLineNumber);\r\n\t\t\t\tthis.arrLinesElement.push(divLineNumber);\r\n\t\t\t\tfromLine++;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn fromLine;\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__setLineNumberVisibility = function(isVisible) \r\n\t{\r\n\t\tif(this.__setting[\"enableLineNumber\"])\r\n\t\t{\r\n\t\t\tthis.__config[\"enableLineNumber\"] = isVisible;\r\n\t\t\tthis.__handleVisibilityOfComponent(this.__divLineNumberContainer,\"enableLineNumber\");\r\n\t\t\tthis.__dispatchInternalEvent(\"lineNumberVisibilityChanged\",{isVisible: isVisible},{isVisible: isVisible});\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__handleVisibilityOfComponent = function(component,property) \r\n\t{\r\n\t\tthis.__setting[property] ? this.util.removeStyleClass(component,\"nsEditorComponentHidden\") : this.util.addStyleClass(component,\"nsEditorComponentHidden\");\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__handleKeySpecialKeys = function(event) \r\n\t{\r\n\t\t// escape, left, right\r\n        if (event.keyCode === 27 || event.keyCode === 37 || event.keyCode === 39)\r\n        {\r\n            setVisible(false);\r\n        }\r\n        // up\r\n        else if (event.keyCode === 38)\r\n        {\r\n            moveSelected(-1);\r\n            event.preventDefault();\r\n            event.stopPropagation();\r\n        }\r\n        // down\r\n        else if (event.keyCode === 40)\r\n        {\r\n            moveSelected(1);\r\n            event.preventDefault();\r\n            event.stopPropagation();\r\n        }\r\n        // page up \r\n        else if (event.keyCode === 33)\r\n        {\r\n            moveSelected(-5);\r\n            event.preventDefault();\r\n        }\r\n        // page down\r\n        else if (event.keyCode === 34)\r\n        {\r\n            moveSelected(5);\r\n            event.preventDefault();\r\n        }\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__getTextFromTextArea = function() \r\n\t{\r\n\t\tvar text = null;\r\n\t\tif(this.__isModeTextArea())\r\n\t\t{\r\n\t\t\ttext  = this.__compTextArea.textContent || this.__compTextArea.innerText;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\ttext = this.__getIFrameText();\r\n\t\t}\r\n\t\treturn text;\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__getHtmlFromTextArea = function() \r\n\t{\r\n\t\tvar text = null;\r\n\t\tif(this.__isModeTextArea())\r\n\t\t{\r\n\t\t\ttext  = this.__compTextArea.innerHTML;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\ttext = this.__getIFrameContent();\r\n\t\t}\r\n\t\tif(text)\r\n\t\t{\r\n\t\t\ttext = text.replace(/^(<p[^>]*>(&nbsp;|&#160;|\\s|\\u00a0|<br \\/>|)<\\/p>[\\r\\n]*|<br \\/>[\\r\\n]*)$/, \"\");\r\n\t\t}\r\n\t\treturn text;\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__setTextIntoTextArea = function(text) \r\n\t{\r\n\t\tif(this.__isModeTextArea())\r\n\t\t{\r\n\t\t\tthis.__compTextArea.innerText = text;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis.__setIFrameText(text);\r\n\t\t}\r\n\t\t//this.__dispatchInternalEvent(\"change\");\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__setHtmlIntoTextArea = function(html) \r\n\t{\r\n\t\tif(this.__isModeTextArea())\r\n\t\t{\r\n\t\t\tthis.__compTextArea.innerHTML = html;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis.__setIFrameContent(html);\r\n\t\t}\r\n\t\t//this.__dispatchInternalEvent(\"change\");\r\n\t};\r\n\t\r\n\t//functions related to IFrame\r\n\tNSEditor.prototype.__getIFrameText = function() \r\n\t{\r\n\t\tvar iframeBody = this.__getIFrameBody();\r\n\t    return (iframeBody ? (iframeBody.textContent || iframeBody.innerText) : null);\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__getIFrameContent = function() \r\n\t{\r\n\t\tvar iframeBody = this.__getIFrameBody();\r\n\t    return (iframeBody ? iframeBody.innerHTML : null);\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__setIFrameText = function(text) \r\n\t{\r\n\t\tvar iframeBody = this.__getIFrameBody();\r\n\t    iframeBody ? iframeBody.innerText = text : null;\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__setIFrameContent = function(html) \r\n\t{\r\n\t\tvar iframeBody = this.__getIFrameBody();\r\n\t    iframeBody ? iframeBody.innerHTML = html : null;\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__getIFrameContentWindow = function(iframe) \r\n\t{\r\n\t\tif(this.__isModeTextArea())\r\n\t\t{\r\n\t\t\treturn null;\r\n\t\t}\r\n\t\tvar contentWindow = null;\r\n\t\tif (iframe.contentWindow)\r\n\t\t{\r\n\t\t\tcontentWindow = iframe.contentWindow;\r\n\t\t}\r\n\t\telse if(iframe.contentDocument)\r\n\t\t{\r\n\t\t\tif(iframe.contentDocument.defaultView)\r\n\t\t\t{\r\n\t\t\t\tcontentWindow = iframe.contentDocument.defaultView;\r\n\t\t\t}\r\n\t\t\telse if (iframe.contentDocument.document)\r\n\t        {\r\n\t        \tcontentWindow = iframe.contentDocument.document;\r\n\t        }\r\n\t        else\r\n\t        {\r\n\t        \tcontentWindow = iframe.contentDocument;\r\n\t        }\r\n\t\t}\r\n\t\treturn contentWindow;\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__getIFrameBody = function() \r\n\t{\r\n\t\tif(this.__isModeTextArea())\r\n\t\t{\r\n\t\t\treturn null;\r\n\t\t}\r\n\t\t//if(!this.__frameBody)\r\n\t\t//{\r\n\t\t\tthis.__frameBody = this.__getIFrameDocument().getElementsByTagName(\"body\")[0];\r\n\t\t//}\r\n\t    return this.__frameBody;\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__getIFrameDocument = function()  \r\n\t{\r\n\t    return this.__isModeTextArea() ? null : (this.__compTextArea.contentDocument || this.__compTextArea.contentWindow.document);\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__disableStyleWithCSS = function() \r\n\t{\r\n\t\tif (this.__browserDetail.isFirefox) \r\n\t\t{\r\n\t\t\t//disable style while inserting in firefox design Mode\r\n\t\t\ttry \r\n\t\t\t{\r\n\t\t\t\tthis.__frameContentDoc.execCommand(\"styleWithCSS\", false, false);\r\n\t\t\t} \r\n\t\t\tcatch (error) \r\n\t\t\t{\r\n\t\t\t\ttry \r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__frameContentDoc.execCommand(\"useCSS\", false, true);\r\n\t\t\t\t} \r\n\t\t\t\tcatch (error2) \r\n\t\t\t\t{\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\t//end of functions related to IFrame\r\n\tNSEditor.prototype.__executeCommand = function(commandName,config,key) \r\n\t{\r\n\t\tif(!config)\r\n\t\t{\r\n\t\t\tconfig = {};\r\n\t\t}\r\n\t\tvar command = config.command || commandName;\r\n\t\tvar arguments = config[\"arguments\"];\r\n\t\tif(config.execCommand)\r\n\t\t{\r\n\t\t\tconfig.execCommand.apply(this);\r\n\t\t}\r\n\t\telse \r\n\t\t{\r\n\t\t\tvar doc = this.__dom.doc;\r\n\t\t\tif(!this.__isModeTextArea())\r\n\t\t\t{\r\n\t\t\t\tdoc = this.__frameContentDoc;\r\n\t\t\t\tthis.__disableStyleWithCSS();\r\n\t\t\t}\r\n\t\t\t// in Firefox untrusted JavaScript is not allowed to access the clipboard\r\n\t\t\ttry \r\n\t\t\t{\r\n\t\t\t\tthis.__dispatchInternalEvent(\"beforeExecCommand\",config,config);\r\n\t\t\t\tif(config.beforeCommand)\r\n\t\t\t\t{\r\n\t\t\t\t\tconfig.beforeCommand(config,key);\r\n\t\t\t\t}\r\n\t\t\t\tthis.__selection.restoreSelection();\r\n\t\t\t\tthis.__selection.setFocus();\r\n\t\t\t\tthis.__execCommand.execute(command, false, arguments);\r\n\t\t\t\t//doc.execCommand(command, false, arguments);\r\n\t\t\t\tthis.__selection.saveSelection();\r\n\t\t\t\tif(config.afterCommand)\r\n\t\t\t\t{\r\n\t\t\t\t\tconfig.afterCommand(config,key);\r\n\t\t\t\t}\r\n\t\t\t\tthis.__dispatchInternalEvent(\"afterExecCommand\",config,config);\r\n\t\t\t} \r\n\t\t\tcatch (error) \r\n\t\t\t{\r\n\t\t\t\tconsole.error(error);\r\n\t\t\t}\r\n\t\t}\r\n\t\t//this.__dispatchInternalEvent(\"change\");\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__orderedListHandler = function(item,key,event)\r\n\t{\r\n\t\t/*var element = this.__selection.getElementUnderCursor();\r\n\t\tvar textArea = this.__getTextArea();\r\n\t\tvar parent = this.util.findParentByCallback(element, function(node) \r\n\t\t{ \r\n\t\t\treturn node && /^UL|OL$/i.test(node.nodeName);\r\n\t\t}, textArea);\r\n        if (parent && this.util.isElementOfType(parent.parentNode,\"p\")) \r\n        {\r\n            var selection = this.__selection.saveSelection();\r\n            this.util.insertElementParentsParent(parent.parentNode);\r\n            for(var count = 0;count < parent.childNodes.length;count++)\r\n            {\r\n            \tvar li = parent.childNodes[count];\r\n            \tif (this.util.isElementOfType(li.lastChild,\"br\")) \r\n            \t{\r\n            \t\tthis.editorUtil.removeNode(li.lastChild);\r\n                }\r\n            }\r\n            this.__selection.restoreSelection(selection);\r\n        }*/\r\n        //editor.setEditorValue();\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__viewSourceCodeHandler = function(item,key,event)\r\n\t{\r\n\t\tif(!this.__txtSourceCode)\r\n\t\t{\r\n\t\t\tthis.__txtSourceCode = this.util.createElement(\"textarea\",this.getID() + \"sourcetextArea\",\"nsEditorSourceTextArea\");\r\n\t\t\t//this.__txtSourceCode.setAttribute(\"disabled\",true);\r\n\t\t\tthis.__divTextAreaContainer.appendChild(this.__txtSourceCode);\r\n\t\t}\r\n\t\t//view source is shown then show editor\r\n\t\tif (this.__isSourceMode)\r\n\t\t{\r\n\t\t\tthis.util.addStyleClass(this.__txtSourceCode,\"nsEditorTextAreaHidden\");\r\n\t\t\tthis.util.removeStyleClass(this.__compTextArea,\"nsEditorTextAreaHidden\");\r\n\t\t\tthis.setHtml(this.__txtSourceCode.value);\r\n\t\t\t//processItems(false);\r\n\t\t}\r\n\t\t//view source is not shown then show viewsource text area\r\n\t\telse\r\n\t\t{\r\n\t\t\tvar html = this.__getHtmlFromTextArea();\r\n\t\t\tthis.util.removeStyleClass(this.__txtSourceCode,\"nsEditorTextAreaHidden\");\r\n\t\t\tthis.util.addStyleClass(this.__compTextArea,\"nsEditorTextAreaHidden\");\r\n\t\t\tthis.__txtSourceCode.value = html;\r\n\t\t\t//processItems(true);\r\n\t\t}\r\n\t\tthis.__isSourceMode = !this.__isSourceMode;\r\n\t\tthis.__placeHolderToggleRef();\r\n\t\tthis.__dispatchInternalEvent(\"viewSourceChanged\",{isSourceMode: this.__isSourceMode,item: item,key: key}, {isSourceMode: this.__isSourceMode,item: item,key: key});\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__emptyDocHandler = function(item,key,event)\r\n\t{\r\n\t\tvar body = this.__getTextArea();\r\n\t\tbody.innerHTML = this.__config.defaultValue;\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__printHandler = function(item,key,event)\r\n\t{\r\n\t\tif(this.__isModeTextArea())\r\n\t\t{\r\n\t\t\tif(!this.__iframePrint)\r\n\t\t\t{\r\n\t\t\t\tthis.__iframePrint = this.util.createElement(\"iframe\",this.getID() + \"EditorPrintFrame\",\"nsEditorPrint\");\r\n\t\t\t\tthis.__iframePrint.name = this.getID() + \"EditorPrintFrame\";\r\n\t\t\t\tthis.__dom.doc.body.appendChild(this.__iframePrint);\r\n\t\t\t}\r\n\t\t\tvar content =  this.__getHtmlFromTextArea();\r\n\t\t\tvar html = \"<!DOCTYPE html><html><head><title>\" + this.__dom.doc.title + \"</title>\";\r\n\t\t\tvar arrStyle = this.__dom.doc.querySelectorAll(\"style\");\r\n\t\t\tif(arrStyle && arrStyle.length > 0)\r\n\t\t\t{\r\n\t\t\t\tfor(var count= 0;count < arrStyle.length; count++)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar style = arrStyle[count].cloneNode(true);\r\n\t\t\t\t\thtml += \"\\n\" + style.outerHTML;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tvar arrLink = this.__dom.doc.querySelectorAll(\"link\");\r\n\t\t\tif(arrLink && arrLink.length > 0)\r\n\t\t\t{\r\n\t\t\t\tfor(var count= 0;count < arrLink.length; count++)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar link = this.__dom.doc.createElement(\"link\");\r\n\t\t\t\t\tlink.rel = arrLink[count].rel;\r\n\t\t\t\t\tlink.href = arrLink[count].href;\r\n\t\t\t\t\tlink.type = \"text/css\";\r\n\t\t\t\t\tlink.media = \"all\";\r\n\t\t\t\t\thtml += \"\\n\" + link.outerHTML;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\thtml +=\"</head><body class=\\\"nsEditorBody\\\" dir=\\\"auto\\\"><div>\" + content + \"</div></body></html>\";\r\n\t\t\tvar self = this;\r\n\t\t\tthis.__iframePrint.onload = function() \r\n\t\t\t{\r\n                setTimeout(function() \r\n                {\r\n                \tvar frame = self.__context.frames[self.getID() + \"EditorPrintFrame\"];\r\n                \tframe.focus();\r\n                \tframe.print();\r\n                \tself.__context.focus();\r\n                }, 0);\r\n            };\r\n            var contentWindow = this.__iframePrint.contentWindow;\r\n            contentWindow.document.open();\r\n            contentWindow.document.write(html);\r\n            contentWindow.document.close();\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis.__executeCommand(\"print\",item,\"print\");\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__previewHandler = function(item,key,event)\r\n\t{\r\n\t\tvar content =  this.__getHtmlFromTextArea();\r\n\t\tcontent = \"<div class='\" + this.__getTextArea().getAttribute(\"class\") + \"'>\" + content + \"</div>\";\r\n\t\tvar objWindow = this.__context.open(\"\",\"_blank\");\r\n\t\tif(!objWindow)\r\n\t\t{\r\n\t\t\tthrow this.util.throwNSError(\"NSEditor\",\"Preview window was not opened.Please deactivate PopUp Blocker for this application\");\r\n\t\t}\r\n\t\tobjWindow.mimeType = \"text/html\";\r\n\t\tvar width = this.__getTextArea().offsetWidth + \"px !important\";\r\n\t\tvar bodyCssClass =  this.__divOuterContainer.getAttribute(\"class\") + \" nsEditorBody\";\r\n\t\tif(this.__isModeTextArea())\r\n\t\t{\r\n\t\t\tvar html = \"\";\r\n            var arrStyle = this.__dom.doc.querySelectorAll(\"style\");\r\n            if(arrStyle && arrStyle.length > 0)\r\n\t\t\t{\r\n\t\t\t\tfor(var count= 0;count < arrStyle.length; count++)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar style = arrStyle[count].cloneNode(true);\r\n\t\t\t\t\thtml += \"\\n\" + style.outerHTML;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tvar arrLink = this.__dom.doc.querySelectorAll(\"link\");\r\n\t\t\tif(arrLink && arrLink.length > 0)\r\n\t\t\t{\r\n\t\t\t\tfor(var count= 0;count < arrLink.length; count++)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar link = this.__dom.doc.createElement(\"link\");\r\n\t\t\t\t\tlink.rel = arrLink[count].rel;\r\n\t\t\t\t\tlink.href = arrLink[count].href;\r\n\t\t\t\t\tlink.type = \"text/css\";\r\n\t\t\t\t\tlink.media = \"all\";\r\n\t\t\t\t\thtml += \"\\n\" + link.outerHTML;\r\n\t\t\t\t}\r\n\t\t\t}\r\n            objWindow.document.write('' +\r\n                '<!DOCTYPE html><html>' +\r\n                '<head>' +\r\n                '<meta charset=\"utf-8\" />' +\r\n                '<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">' +\r\n                '<title>' + \"Preview\" + '</title>' +\r\n                html +\r\n                '</head>' +\r\n                '<body class=\"' + bodyCssClass + '\" style=\"width:' + width + '; border:1px solid #ccc; margin:10px auto !important; height:auto !important;\">' + content + '</body>' +\r\n                '</html>'\r\n            );\r\n            \r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tobjWindow.document.write('' +\r\n                '<!DOCTYPE html><html>' +\r\n                '<head>' +\r\n                this.__getDocument().head.innerHTML +\r\n                '<style>body {overflow:auto !important; width:' + width + '; border:1px solid #ccc; margin: 10px auto !important; height:auto !important;}</style>' +\r\n                '</head>' +\r\n                '<body ' + bodyCssClass + '>' + content + '</body>' +\r\n                '</html>'\r\n            );\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__pageBreakForPrintingHandler = function(item,key,event)\r\n\t{\r\n\t\tvar divPageBreak = \"<div class=\\\"nsEditorPageBreak\\\" style=\\\"page-break-after: always\\\" title=\\\"Page Break\\\"></div>\";\r\n\t\tthis.__selection.insertHTML(divPageBreak);\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__getScrollComponent = function() \r\n\t{\r\n\t\tvar component = this.__isModeTextArea() ? this.__divTextAreaContainer : this.__getIFrameBody();\r\n\t\treturn component;\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__getScrollableComponent = function() \r\n\t{\r\n\t\tvar element = this.__isModeTextArea() ? this.__divTextAreaContainer : this.__frameContentWindow;\r\n\t\treturn element;\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__getTextArea = function() \r\n\t{\r\n\t\tvar component = this.__isModeTextArea() ? this.__compTextArea : this.__getIFrameBody();\r\n\t\treturn component;\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__getDocument = function() \r\n\t{\r\n\t\tvar component = this.__isModeTextArea() ? this.__dom.doc : this.__getIFrameDocument();\r\n\t\treturn component;\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__getWindow = function() \r\n\t{\r\n\t\tvar component = this.__isModeTextArea() ? this.__context : this.__frameContentWindow;\r\n\t\treturn component;\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__getListenerComponent = function() \r\n\t{\r\n\t\tvar listenerComponent = this.__isModeTextArea() ? this.__compTextArea : this.__frameContentWindow;\r\n\t\treturn listenerComponent;\r\n\t};\r\n\r\n\tNSEditor.prototype.__isModeTextArea = function() \r\n\t{\r\n\t\treturn (this.__config[\"mode\"] !== NSEditor.MODE_IFRAME);\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__resizeContainer = function(width,height) \r\n\t{\r\n\t\tthis.__setHeight(height);\r\n\t\tthis.__setWidth(width);\r\n\t\tthis.__handleLineNumberOnResize();\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__dispatchEvent = function(eventType,data,param,bubbles,cancelable)\r\n\t{\r\n\t\tthis.util.dispatchEvent(this.__baseComponent,eventType,data,param,bubbles,cancelable);\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__dispatchInternalEvent = function(eventType,data,param,bubbles,cancelable)\r\n\t{\r\n\t\tthis.util.dispatchEvent(this.__baseComponent,this.__getInternalEvent(eventType),data,param,bubbles,cancelable);\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__listenInternalEvent = function(eventType,callback)\r\n\t{\r\n\t\tthis.util.addEvent(this.__baseComponent,this.__getInternalEvent(eventType),callback);\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__removeInternalEvent = function(eventType,callback)\r\n\t{\r\n\t\tthis.util.removeEvent(this.__baseComponent,this.__getInternalEvent(eventType),callback);\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__addEvent = function(eventType,listener)\r\n\t{\r\n\t\tthis.util.addEvent(this.__baseComponent,eventType,listener);\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__getInternalEvent = function(eventType)\r\n\t{\r\n\t\tvar retType = \"\";\r\n\t\tvar joinBy = \" \";\r\n\t\tvar arrEventType = eventType.split(\" \");\r\n\t\tfor(var count = 0;count < arrEventType.length;count++)\r\n\t\t{\r\n\t\t\tretType += joinBy + \"__\" + arrEventType[count];\r\n\t\t}\r\n\t\tif(retType)\r\n\t\t{\r\n\t\t\tretType = retType.substring(joinBy.length);\r\n\t\t}\r\n\t\treturn retType;\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__height = function(height)\r\n\t{\r\n\t\tif(!this.util.isUndefinedOrNull(height))\r\n\t\t{\r\n\t\t\tthis.util.css(this.__divOuterContainer,\"height\",height);\r\n\t\t}\r\n\t\tvar baseMeasurement = this.__divOuterContainer.getBoundingClientRect();\r\n\t\treturn baseMeasurement.height;\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__width = function(width)\r\n\t{\r\n\t\tif(!this.util.isUndefinedOrNull(width))\r\n\t\t{\r\n\t\t\tthis.util.css(this.__divOuterContainer,\"width\",width);\r\n\t\t}\r\n\t\tvar baseMeasurement = this.__divOuterContainer.getBoundingClientRect();\r\n\t\treturn baseMeasurement.width;\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__heightBody = function(height)\r\n\t{\r\n\t\tif(!this.util.isUndefinedOrNull(height))\r\n\t\t{\r\n\t\t\tthis.util.css(this.__divBodyContainer,\"height\",height);\r\n\t\t}\r\n\t\tvar baseMeasurement = this.__divBodyContainer.getBoundingClientRect();\r\n\t\treturn baseMeasurement.height;\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__handleLineNumberOnResize = function()\r\n\t{\r\n\t\tif(this.__divLineNumberWrapper)\r\n\t\t{\r\n\t\t\tvar lineNumberHeight = 15;\r\n\t\t\tvar listenerComponent = this.__getScrollComponent();\r\n\t\t\t\r\n\t\t\tvar scrollTop = listenerComponent.scrollTop;\r\n\t\t\tvar firstLine = Math.floor((scrollTop / lineNumberHeight) + 1);\r\n\t\t\tvar remainingScroll = (scrollTop / lineNumberHeight) % 1;\r\n\r\n\t\t\tthis.__drawLineNumbers(firstLine);\r\n\t\t\tthis.__divLineNumberWrapper.style.marginTop = (-1 * (remainingScroll * lineNumberHeight)) + \"px\";\r\n\t\t\tthis.__paddingHorizontal = parseInt(this.util.getStyleValue(this.__divOuterContainer,\"border-left-width\",false)) +\r\n\t\t\t\t\t\t\t\t\tparseInt(this.util.getStyleValue(this.__divOuterContainer,\"border-right-width\",false)) + \r\n\t\t\t\t\t\t\t\t\tparseInt(this.util.getStyleValue(this.__divOuterContainer,\"padding-left\",false)) + \r\n\t\t\t\t\t\t\t\t\tparseInt(this.util.getStyleValue(this.__divOuterContainer,\"padding-right\",false));\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__getWrappedContent = function(content) \r\n\t{\r\n\t\tif(content)\r\n\t\t{\r\n\t\t\tvar isPFound = content.match(/<\\/?p>/gi);\r\n\t\t\tif (!isPFound) \r\n\t\t\t{\r\n\t\t\t\treturn \"<p>\" + content + \"</p>\";\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn content;\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__setDefaultTag = function()\r\n\t{\r\n\t\tvar text = this.__getTextFromTextArea();\r\n\t\tvar htmlText = this.__getHtmlFromTextArea();\r\n\t\tif(text && text.trim().length === 0 && htmlText != this.__defaultContent)\r\n\t\t{\r\n\t\t\tthis.__isInternalHTMLChange = true;\r\n\t\t\tvar body = this.__getTextArea();\r\n\t\t\tbody.innerHTML = this.__defaultContent;\r\n\t\t\tthis.__isInternalHTMLChange = false;\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__getPastedHTML = function(event)\r\n\t{\r\n\t\tvar objReturn = {text:\"\",html:\"\",rtf:\"\"};\r\n\t\tif (this.__context.clipboardData && this.__context.clipboardData.getData) \r\n        { \r\n\t\t\t\r\n        }\r\n\t\telse if (event.clipboardData && event.clipboardData.getData) \r\n        {\r\n\t\t\tobjReturn.text = event.clipboardData.getData(\"text/plain\");\r\n\t\t\tobjReturn.html = event.clipboardData.getData(\"text/html\");\r\n\t\t\tobjReturn.rtf = event.clipboardData.getData(\"text/rtf\");\r\n        }\r\n\t\treturn objReturn;\r\n\t};\r\n\t\r\n\t//Placeholder functions\r\n\tthis.__compPlaceHolder = null;\r\n\tthis.__placeHolderToggleRef = null;\r\n\tNSEditor.prototype.__createPlaceHolder = function() \r\n\t{\r\n\t\tif(this.__config[\"placeholder\"])\r\n\t\t{\r\n\t\t\tif(!this.__compPlaceHolder)\r\n\t\t\t{\r\n\t\t\t\tthis.__compPlaceHolder = this.util.createElement(\"span\",this.getID() + \"Placeholder\",\"nsEditorPlaceholder\");\r\n\t\t\t\tthis.__compPlaceHolder.appendChild(this.__dom.doc.createTextNode(this.__config[\"placeholder\"]));\r\n\t\t\t}\r\n\t\t\tif(!this.editorUtil.isEditable())\r\n\t\t\t{\r\n\t\t\t\tthis.__removePlaceHolder();\r\n\t\t\t}\r\n\t\t\tif(!this.__placeHolderToggleRef)\r\n\t\t\t{\r\n\t\t\t\tthis.__placeHolderToggleRef = this.util.debounce(this.__togglePlaceHolder.bind(this),10);\r\n\t\t\t\tthis.__placeHolderToggleRef();\r\n\t\t\t\tthis.__addListenerToPlaceHolder();\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__addListenerToPlaceHolder = function() \r\n\t{\r\n\t\tthis.__listenInternalEvent(\"textAreaInitialized change focus keyup mouseup keydown mousedown changePlace\",this.__placeHolderToggleRef);\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__setPlaceHolderPosition = function() \r\n\t{\r\n\t\tif(this.__isPlaceHolderVisible())\r\n\t\t{\r\n\t\t\tvar doc = this.__getDocument();\r\n\t\t\tvar win = this.__getWindow();\r\n\t\t\tif(doc && win)\r\n\t\t\t{\r\n\t\t\t\tvar getPropValue = function(value)\r\n\t\t\t\t{\r\n\t\t\t\t\tif(value == \"\")\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t}\r\n\t\t\t\t\treturn parseInt(value, 10);\r\n\t\t\t\t};\r\n\t\t\t\tvar textArea = this.__getTextArea();\r\n\t\t\t\tvar marginTop = 0;\r\n\t\t\t\tvar marginLeft = 0;\r\n\t\t\t\tvar paddingTop = 0;\r\n\t\t\t\tvar paddingLeft = 0;\r\n\t\t\t\tvar firstChild = textArea.firstChild;\r\n\t\t\t\tvar textAreaStyle = win.getComputedStyle(textArea);\r\n\t\t\t\tvar css = {};\r\n\t\t\t\tif(firstChild && this.util.isElement(firstChild))\r\n\t\t\t\t{\r\n\t\t\t\t\t var childStyle = win.getComputedStyle(firstChild);\r\n\t\t\t         marginTop = getPropValue(childStyle.getPropertyValue(\"margin-top\"));\r\n\t\t\t         marginLeft = getPropValue(childStyle.getPropertyValue(\"margin-left\"));\r\n\t\t\t         paddingTop = getPropValue(childStyle.getPropertyValue(\"padding-top\"));\r\n\t\t\t         paddingLeft = getPropValue(childStyle.getPropertyValue(\"padding-left\"));\r\n\t\t\t         css = {fontSize: getPropValue(childStyle.getPropertyValue(\"font-size\")),lineHeight: getPropValue(childStyle.getPropertyValue(\"line-height\"))};\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t css = {fontSize: getPropValue(textAreaStyle.getPropertyValue(\"font-size\")),lineHeight: getPropValue(textAreaStyle.getPropertyValue(\"line-height\"))};\r\n\t\t\t\t}\r\n\t\t\t\tcss.display = \"block\";\r\n\t\t\t\tcss.marginTop = Math.max(getPropValue(textAreaStyle.getPropertyValue(\"margin-top\")), marginTop);\r\n\t\t\t\tcss.marginLeft = Math.max(getPropValue(textAreaStyle.getPropertyValue(\"margin-left\")), marginLeft);\r\n\t\t\t\tcss.paddingTop = Math.max(getPropValue(textAreaStyle.getPropertyValue(\"padding-top\")), paddingTop);\r\n\t\t\t\tcss.paddingLeft = Math.max(getPropValue(textAreaStyle.getPropertyValue(\"padding-left\")), paddingLeft);\r\n\t\t\t\tthis.util.css(this.__compPlaceHolder,css);\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__togglePlaceHolder = function() \r\n\t{\r\n\t\tif(this.__compPlaceHolder)\r\n\t\t{\r\n\t\t\tvar visible = true;\r\n\t\t\tif(this.__txtSourceCode)\r\n\t\t\t{\r\n\t\t\t\tvisible = false;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tvisible = this.__isTextAreaBlank();\r\n\t\t\t}\r\n\t\t\tvisible ? this.__addPlaceHolder() : this.__removePlaceHolder();\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__addPlaceHolder = function() \r\n\t{\r\n\t\tif(!this.__isPlaceHolderVisible())\r\n\t\t{\r\n\t\t\tthis.__divTextAreaContainer.appendChild(this.__compPlaceHolder);\r\n\t\t}\r\n\t\tthis.__setPlaceHolderPosition();\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__removePlaceHolder = function() \r\n\t{\r\n\t\tif(this.__isPlaceHolderVisible())\r\n\t\t{\r\n\t\t\tthis.__compPlaceHolder.parentNode.removeChild(this.__compPlaceHolder);\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__isPlaceHolderVisible = function() \r\n\t{\r\n\t\treturn (this.__compPlaceHolder && this.__compPlaceHolder.parentNode);\r\n\t};\r\n\t\r\n\t//end of Placeholder functions\r\n\t//FixedDiv functions (for Modal,ContextMenu etc)\r\n\tthis.__compFixed = null;\r\n\tNSEditor.prototype.__createFixedComp = function() \r\n\t{\r\n\t\tif(!this.__compFixed)\r\n\t\t{\r\n\t\t\tthis.__compFixed = this.util.createDiv(this.getID() + \"_FixedComp\",\"nsEditorFixedComp\");\r\n\t\t\tthis.__dom.doc.body.appendChild(this.__compFixed);\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__getFixedComp = function() \r\n\t{\r\n\t\tif(!this.__compFixed)\r\n\t\t{\r\n\t\t\tthis.__createFixedComp();\r\n\t\t}\r\n\t\treturn this.__compFixed;\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__isTextAreaBlank = function() \r\n\t{\r\n\t\t/*var textArea = this.__getTextArea();\r\n\t\tif(textArea.children.length === 0)\r\n\t\t{\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\tvar getText = function(paramText)\r\n\t\t{\r\n\t\t\tvar regex = /[\\uFEFF]/g;\r\n\t\t\tparamText = paramText.replace(regex,\"\");\r\n\t\t\tparamText = paramText.replace(/(\\r\\n|\\n|\\r)/gm,\"\");\r\n\t\t\treturn paramText;\r\n\t\t};\r\n\t\tif(textArea.children.length === 1)\r\n\t\t{\r\n\t\t\tvar firstChild = textArea.firstChild;\r\n\t\t\tif(this.editorUtil.REGEX_EMPTY_TAGS.test(firstChild.nodeName))\r\n\t\t\t{\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\tvar text = this.__getTextFromTextArea();\r\n\t\t\tif(getText(text).length == 0)\r\n\t\t\t{\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\t\tvar self = this;\r\n\t\tvar isEmpty = function(paramNode)\r\n\t\t{\r\n\t\t\tif(!paramNode) \r\n\t\t\t{\r\n\t            return true;\r\n\t        }\r\n\t\t\tif(self.util.isTextNode(paramNode))\r\n\t\t\t{\r\n\t\t\t\treturn paramNode.nodeValue === null || paramNode.nodeValue.trim().length === 0;\r\n\t\t\t}\r\n\t\t\tvar regexNonEmptyTags = /^(img|svg|canvas|input|textarea|form)$/;\r\n\t\t\tif(regexNonEmptyTags.test(paramNode.nodeName.toLowerCase()))\r\n\t\t\t{\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\tif(self.util.isElement(paramNode))\r\n\t\t\t{\r\n\t\t\t\tvar text = paramNode.textContent || paramNode.innerText;\r\n\t\t\t\tif(getText(text).length == 0)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif(!self.util.isElement(paramNode))\r\n\t\t\t{\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t\treturn false;\r\n\t\t};\r\n\t\tvar arrElements = textArea.querySelectorAll(\"*\");\r\n\t\tfor(var count = 0;count < arrElements.length;count++)\r\n\t\t{\r\n\t\t\tvar ele = arrElements[count];\r\n\t\t\tif(!isEmpty(ele) && !(ele.tagName.toLowerCase() == \"br\"))\r\n\t\t\t{\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn true;*/\r\n\t\tvar textArea = this.__getTextArea();\r\n\t\tif (textArea.firstChild) \r\n\t\t{\r\n\t\t\tvar self = this;\r\n\t\t\tvar firstChild = textArea.firstChild;\r\n\t\t    if(this.editorUtil.REGEX_EMPTY_TAGS.test(firstChild.nodeName))\r\n\t\t    {\r\n\t\t    \treturn false;\r\n\t\t    }\r\n\t\t    var nextNode = this.util.findNextNode(firstChild,function(node) \r\n\t\t    { \r\n\t\t    \treturn node && !self.editorUtil.isEmptyTextNode(node); \r\n\t\t    }, textArea);\r\n\t\t    if (this.util.isTextNode(firstChild) && !nextNode) \r\n\t\t    {\r\n\t\t    \treturn self.editorUtil.isEmptyTextNode(firstChild);\r\n\t\t    }\r\n\t\t    if (!nextNode) \r\n\t\t    {\r\n\t\t    \tvar value = this.util.loopAllChildren(firstChild,function(paramElement) \r\n\t\t    \t{ \r\n\t\t    \t\treturn self.editorUtil.isEmptyNode(paramElement) || self.util.isElementOfType(paramElement,\"br\"); \r\n\t\t    \t});\r\n\t\t    \tif(value)\r\n\t\t    \t{\r\n\t\t    \t\treturn true;\r\n\t\t    \t}\r\n\t\t    }\r\n\t\t    return false;\r\n\t    }\r\n\t    return true;   \r\n\t};\r\n\t\r\n\tNSEditor.prototype.__getStyleValue = function(styleValue) \r\n\t{\r\n        return parseInt(styleValue, 10) || 0;\r\n    };\r\n    \r\n    NSEditor.prototype.__initializeModules = function() \r\n\t{\r\n    \tthis.editorUtil = new NSEditorUtil(this);\r\n\t\tthis.__selection = new NSSelection(this);\r\n\t\tthis.__toolBar = new NSToolBar(this);\r\n\t\tthis.__execCommand = new NSExecCommand(this);\r\n\t\tthis.__stack = new NSStack(this);\r\n\t};\r\n    \r\n    //section of functions for util\r\n    NSEditor.prototype.__getUtilClass = function(utilClassName) \r\n\t{\r\n\t\tif(NSEditor.__util)\r\n\t\t{\r\n\t\t\tfor(var utilName in NSEditor.__util)\r\n\t\t\t{\r\n\t\t\t\tif(utilName == utilClassName)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn NSEditor.__util[utilName];\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis.util.throwNSError(\"NSEditor\",utilClassName + \" util has not been loaded.\");\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__getUtilInstance = function(utilClassName,utilInstanceID,plugginName,objPluggin,utilSetting) \r\n\t{\r\n\t\tvar utilClass = this.__getUtilClass(utilClassName);\r\n\t\tif(utilClass)\r\n\t\t{\r\n\t\t\t!this.__utilInstance[utilClassName] && (this.__utilInstance[utilClassName] = {});\r\n\t\t\t!this.__utilInstance[utilClassName][utilInstanceID] && (this.__utilInstance[utilClassName][utilInstanceID] = {});\r\n\t\t\tvar objUtilPluggin = this.__utilInstance[utilClassName][utilInstanceID][plugginName];\r\n\t\t\tif(objUtilPluggin && objUtilPluggin.instance)\r\n\t\t\t{\r\n\t\t\t\treturn objUtilPluggin.instance;\r\n\t\t\t}\r\n\t\t\tvar objUtil = new utilClass(this,objPluggin,utilSetting);\r\n\t\t\tobjUtil.id = utilInstanceID;\r\n\t\t\tobjUtil.selection = this.__selection;\r\n\t\t\tobjUtil.util = this.util;\r\n\t\t\tobjUtil.editorUtil = this.editorUtil;\r\n\t\t\tvar item = {instance: objUtil,instanceID: utilInstanceID,plugginInstance: objPluggin,utilSetting: utilSetting};\r\n\t\t\tthis.__utilInstance[utilClassName][utilInstanceID][plugginName] = item;\r\n\t\t\treturn objUtil;\r\n\t\t}\r\n\t};\r\n\t//end of section of functions for util\r\n    \r\n\t//section of functions for pluggin\r\n\tNSEditor.prototype.__initializePlugins = function() \r\n\t{\r\n\t\tthis.__pluginsInstances = {};\r\n\t\tif(NSEditor.__plugins)\r\n\t\t{\r\n\t\t\tfor(var plugginName in NSEditor.__plugins)\r\n\t\t\t{\r\n\t\t\t\tvar objPlugin = new NSEditor.__plugins[plugginName](this);\r\n\t\t\t\tobjPlugin.nsEditor = this;\r\n\t\t\t\tobjPlugin.selection = this.__selection;\r\n\t\t\t\tobjPlugin.util = this.util;\r\n\t\t\t\tobjPlugin.editorUtil = this.editorUtil;\r\n\t\t\t\tthis.__pluginsInstances[plugginName] = {prototype: NSEditor.__plugins[plugginName],instance: objPlugin};\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__callSetSettingsInPluggin = function() \r\n\t{\r\n\t\tthis.__callFunctionInPlugins(\"setSettings\");\r\n\t\tthis.__dispatchInternalEvent(\"setSettings\");\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__callInitializeInPluggin = function() \r\n\t{\r\n\t\tthis.__callFunctionInPlugins(\"initialize\");\r\n\t\tthis.__dispatchInternalEvent(\"initialize\");\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__callComponentsInitializedInPluggin = function() \r\n\t{\r\n\t\tthis.__callFunctionInPlugins(\"componentsInitialized\");\r\n\t\tthis.__dispatchInternalEvent(\"componentsInitialized\");\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__callDestroyInPluggin = function() \r\n\t{\r\n\t\tthis.__callFunctionInPlugins(\"destroy\");\r\n\t\tthis.__dispatchInternalEvent(\"destroy\");\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__callResizedInPluggin = function() \r\n\t{\r\n\t\tthis.__callFunctionInPlugins(\"resized\");\r\n\t\tthis.__dispatchInternalEvent(\"resized\");\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__callAddStyleIFrameInPluggin = function() \r\n\t{\r\n\t\treturn this.__callFunctionInPlugins(\"addStyleInIFrame\");\r\n\t\tthis.__dispatchInternalEvent(\"addStyleInIFrame\");\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__callFunctionInPlugins = function(functionName,arrParams) \r\n\t{\r\n\t\tvar arrRetValue = [];\r\n\t\tif(this.__pluginsInstances)\r\n\t\t{\r\n\t\t\tfor(var plugginName in this.__pluginsInstances)\r\n\t\t\t{\r\n\t\t\t\tvar objPlugin = this.__pluginsInstances[plugginName].instance;\r\n\t\t\t\tif(objPlugin && objPlugin[functionName])\r\n\t\t\t\t{\r\n\t\t\t\t\tvar retValue = objPlugin[functionName].apply(objPlugin,arrParams);\r\n\t\t\t\t\tif(!this.util.isUndefined(retValue))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tarrRetValue.push({name: plugginName,value: retValue});\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 arrRetValue;\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__callPromptBox = function(titleHtml,message,okText,cancelText,okHandler,cancelHandler) \r\n\t{\r\n\t\tif(this.__config[\"promptBoxCallback\"])\r\n\t\t{\r\n\t\t\tthis.__config[\"promptBoxCallback\"](titleHtml,message,okText,cancelText,okHandler,cancelHandler);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tvar closeConfirmBox = function(event)\r\n\t\t\t{\r\n\t\t\t\tthis.__dom.doc.body.removeChild(divContainer);\r\n\t\t\t};\r\n\t\t\tvar divContainer = this.util.createDiv(\"nsEditorConfirmContainer\",\"nsEditorPromptOvelay\");\r\n\t\t\tvar content = \"<div class='nsEditorPrompt'>\" +\r\n\t    \t\t\t\t\t\t\"<header>\" +\r\n\t    \t\t\t\t\t\t\t\"<h3> \" + titleHtml + \" </h3> \" +\r\n\t    \t\t\t\t\t\t\t\"<i id='nsEditorIconClose' class='fa fa-close'></i>\" +\r\n\t    \t\t\t\t\t\t\"</header>\" +\r\n\t        \t\t\t\t\t\"<div class='nsEditorPromptBody'>\" +\r\n\t        \t\t\t\t\t\t\" <p> \" + message + \" </p> \" +\r\n\t        \t\t\t\t\t\"</div>\" +\r\n\t        \t\t\t\t\t\"<footer>\" +\r\n\t\t\t\t\t\t\t         \"<div class='controls'>\" +\r\n\t\t\t\t\t\t\t             \" <button id='btnEditorConfirmOk' class='nsEditorPromptButton nsEditorPromptButtonDanger'>\" + okText + \"</button> \" +\r\n\t\t\t\t\t\t\t             \" <button id='btnEditorConfirmCancel' class='nsEditorPromptButton nsEditorPromptButtonDefault'>\" + cancelText + \"</button> \" +\r\n\t\t\t\t\t\t\t         \"</div>\" +\r\n\t\t\t\t\t\t\t    \"</footer>\" +\r\n\t\t\t\t\t\t   \"</div>\";\r\n\t\t\tdivContainer.innerHTML = content;\r\n\t\t\tthis.__dom.doc.body.insertBefore(divContainer,this.__dom.doc.body.firstChild);\r\n\t\t\tthis.util.addEvent(this.__dom.doc.getElementById(\"nsEditorIconClose\"),\"click\",closeConfirmBox);\r\n\t\t\tthis.util.addEvent(this.__dom.doc.getElementById(\"btnEditorConfirmOk\"),\"click\",function(event){\r\n\t\t\t\tif(okHandler)\r\n\t\t\t\t{\r\n\t\t\t\t\tokHandler(event);\r\n\t\t\t\t}\r\n\t\t\t\tcloseConfirmBox();\r\n\t\t\t});\r\n\t\t\tthis.util.addEvent(this.__dom.doc.getElementById(\"btnEditorConfirmCancel\"),\"click\",function(event){\r\n\t\t\t\tif(cancelHandler)\r\n\t\t\t\t{\r\n\t\t\t\t\tcancelHandler(event);\r\n\t\t\t\t}\r\n\t\t\t\tcloseConfirmBox();\r\n\t\t\t});\r\n\t\t}\r\n\t};\r\n\t//end of section of functions for pluggin\r\n\r\n\tNSEditor.prototype.__addElement = function (node,config) \r\n\t{\r\n\t\tthis.__selection.restoreSelection();\r\n\t\tif(node)\r\n\t\t{\r\n\t\t\tconfig = config || {};\r\n\t\t\tvar doc = this.__getDocument();\r\n\t\t\tvar win = this.__getWindow();\r\n\t\t\tvar textArea = this.__getTextArea();\r\n\t\t\tvar html = this.getHtml();\r\n\t\t\tif(html == this.__defaultContent)\r\n\t\t\t{\r\n\t\t\t\tthis.util.removeAllChildren(textArea);\r\n\t\t\t}\r\n\t\t\tvar element = this.__selection.getElementUnderCursor();\r\n\t        var isCollapsed = this.__selection.isCollapsed();\r\n\t        if (element && isCollapsed) \r\n\t        {\r\n\t        \tvar self = this;\r\n\t        \tvar blockElement = this.editorUtil.getClosestElement(element,function(node) \r\n\t        \t{ \r\n\t        \t\treturn self.editorUtil.isBlock(node,win); \r\n\t        \t},textArea);\r\n\t            if (config.insertAfterSelectedNode && blockElement && blockElement !== textArea) \r\n\t            {\r\n\t            \tif(!config.insertAfterNodeCallback || config.insertAfterNodeCallback(blockElement))\r\n\t            \t{\r\n\t            \t\tthis.__selection.setCursorAfter(blockElement);\r\n\t            \t}\r\n\t            }\r\n\t        }\r\n\t        this.__selection.insertNode(doc.createTextNode(\"\\n\"));\r\n\t        this.__selection.insertNode(node,Boolean.parse(config.insertCursorAfter));\r\n\t        config.afterInsertCallback && config.afterInsertCallback();\r\n\t        if(config.dispatchEvents && config.dispatchEvents.length)\r\n\t        {\r\n\t        \tfor(var count = 0;count < config.dispatchEvents.length;count++)\r\n\t        \t{\r\n\t        \t\tvar itemEvent = config.dispatchEvents[count];\r\n\t        \t\tthis.__dispatchInternalEvent(itemEvent.name,itemEvent.args,itemEvent.args);\r\n\t        \t}\r\n\t        }\r\n\t\t}\r\n\t};\r\n\t\r\n\t\r\n    \r\n    NSEditor.prototype.__checkCharCount = function(element,charCounterType) \r\n    {\r\n    \tvar maxCount = this.__config.maxCharCount\r\n        if (maxCount) \r\n        {\r\n            var countType = charCounterType || this.__config.charCounterType;\r\n            var length = this.editorUtil.getCharLength((typeof element === \"string\" ? element : this.__isCharTypeHTML() ? element.outerHTML : element.textContent), countType);\r\n            if (length > 0 && length + this.__getCharCount(countType) > maxCount) \r\n            {\r\n            \t//TODO:indicate here that character has increased maxCharCount\r\n                return false;\r\n            }\r\n        }\r\n        return true;\r\n    };\r\n    \r\n    NSEditor.prototype.__getCharCount = function(charCounterType) \r\n    {\r\n        charCounterType = (typeof charCounterType === \"string\") ? charCounterType : this.__config.charCounterType;\r\n        var count = this.editorUtil.getCharLength((this.__isCharTypeHTML() ? this.getHtml() : this.getText()), charCounterType);\r\n        return count;\r\n    };\r\n\r\n\t//function related to Media sources like img,audio,video\r\n\tNSEditor.prototype.__createCustomMediaContainerContainer = function(mediaContainer,cssClass,contenteditable) \r\n\t{\r\n\t\tcontenteditable = Boolean.parse(contenteditable);\r\n        var container = this.util.createDiv(null,\"nsEditorMediaContainerContainer\");\r\n        if(cssClass)\r\n        {\r\n        \tthis.util.addStyleClass(cssClass);\r\n        }\r\n        container.setAttribute(\"contenteditable\",contenteditable);\r\n        if(mediaContainer)\r\n        {\r\n        \tcontainer.appendChild(mediaContainer);\r\n        }\r\n        return container;\r\n    };\r\n\r\n    NSEditor.prototype.__createCustomMediaContainer = function(element,parent) \r\n    {\r\n        var container = this.util.createDiv(null,\"nsEditorMediaContainer\");\r\n        if(element)\r\n        {\r\n        \tcontainer.appendChild(element);\r\n        }\r\n        if(parent)\r\n        {\r\n        \tparent.appendChild(container);\r\n        }\r\n        return container;\r\n    };\r\n\r\n    NSEditor.prototype.__createCustomMediaCaption = function(caption,parent) \r\n    {\r\n        var divCaption = this.util.createDiv(null,\"nsEditorMediaCaption\");\r\n        divCaption.setAttribute(\"contenteditable\", true);\r\n        var divContent = this.util.createDiv(null,\"nsEditorMediaCaptionContent\");\r\n        divContent.innerHTML = caption;\r\n        divCaption.appendChild(divContent);\r\n        if(parent)\r\n        {\r\n        \tparent.appendChild(divCaption);\r\n        }\r\n        return divCaption;\r\n    };\r\n\t\r\n\t//end of function related to Media sources like img,audio,video\r\n\t\r\n\tNSEditor.prototype.__isCharTypeHTML = function() \r\n    {\r\n\t\treturn (this.__config.charCounterType == \"byte-html\")\r\n    };\r\n    \t\r\n\t//function using the editor\r\n\t\r\n\tthis.__funcID = null;\r\n\tNSEditor.prototype.__funcExecuted = function(funcID) \r\n\t{\r\n\t\tthis.__funcID = funcID;\r\n\t};\r\n\t\r\n\tNSEditor.prototype.__isFuncExecuted = function(funcID) \r\n\t{\r\n\t\tvar retValue = (this.__funcID == funcID);\r\n\t\treturn retValue;\r\n\t};\r\n\t\r\n\t//end of function using the editor \r\n    \r\n\tNSEditor.TOOLBAR_BUTTONS_BOLD = \"bold\";\r\n\tNSEditor.TOOLBAR_BUTTONS_ITALIC = \"italic\";\r\n\tNSEditor.TOOLBAR_BUTTONS_UNDERLINE = \"underline\";\r\n\tNSEditor.TOOLBAR_BUTTONS_STRIKETHROUGH = \"strikeThrough\";\r\n\tNSEditor.TOOLBAR_BUTTONS_SUBSCRIPT = \"subscript\";\r\n\tNSEditor.TOOLBAR_BUTTONS_SUPERSCRIPT = \"superscript\";\r\n\tNSEditor.TOOLBAR_BUTTONS_FONTFAMILY = \"fontFamily\";\r\n\tNSEditor.TOOLBAR_BUTTONS_FONTSIZE = \"fontSize\";\r\n\tNSEditor.TOOLBAR_BUTTONS_PARAGRAPHFORMAT = \"paragraphFormat\";\r\n\tNSEditor.TOOLBAR_BUTTONS_ALIGN = \"align\";\r\n\tNSEditor.TOOLBAR_BUTTONS_ORDEREDLIST = \"orderedList\";\r\n\tNSEditor.TOOLBAR_BUTTONS_UNORDEREDLIST = \"unorderedList\";\r\n\tNSEditor.TOOLBAR_BUTTONS_UNDO = \"undo\";\r\n\tNSEditor.TOOLBAR_BUTTONS_REDO = \"redo\";\r\n\tNSEditor.MODE_TEXTAREA = \"textArea\";\r\n\tNSEditor.MODE_IFRAME = \"iframe\";\r\n\t\r\n\treturn NSEditor;\r\n})();\r\nnsModuleExport(this,\"NSEditor\",NSEditor);\"use strict\";\r\n/*https://www.brainbell.com/javascript/making-resizable-table-js.html*/\r\nvar NSResizableTable = (function()\r\n{\r\n\tfunction NSResizableTable(table,setting,doc)\r\n\t{\r\n\t\tthis.__table = table;\r\n\t\tthis.__setting = setting;\r\n\t\tthis.__doc = doc;\r\n\t\tthis.util = new NSUtil();\t\r\n\t\t\r\n\t\tthis.__config = null;\r\n\t\tthis.__dom = null;\r\n\t    this.__id = null;\r\n\t    this.__origTableProp = {};\r\n\t    this.__arrResizer = [];\r\n\t    this.__objDrag = null;\r\n\t    this.__initialize();\r\n\t};\r\n\t\r\n\tNSResizableTable.prototype.__initialize = function()\r\n\t{\r\n\t\tif(this.util.hasStyleClass(this.__table,\"nsResizableTable\"))\r\n\t\t{\r\n\t\t\tthis.util.warning(\"NSResizableTable\",\"Table has already been processed\");\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis.__dom = this.util.getDomVariables();\r\n\t\tthis.__setSetting();\r\n\t\tthis.util.addStyleClass(this.__table,\"nsResizableTable\");\r\n\t\tthis.__initCols();\r\n\t};\r\n\t\r\n\tNSResizableTable.prototype.__setSetting = function()\r\n\t{\r\n\t\tvar setting = this.__setting ? this.__setting : {};\r\n\t\tthis.__config = {\r\n\t\t\t\tgetRowCallback: setting[\"getRowCallback\"]\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSResizableTable.prototype.__initCols = function()\r\n\t{\r\n\t\tvar table = this.__table;\r\n\t\tvar row = table.getElementsByTagName(\"tr\")[0];\r\n\t\tif(this.__config.getRowCallback)\r\n\t\t{\r\n\t\t\trow = this.__config.getRowCallback(table,this)\r\n\t\t}\r\n\t\tvar arrCols = row ? row.children : null;\r\n\t\tif(arrCols)\r\n\t\t{\r\n\t\t\tthis.__origTableProp[\"overflow\"] = table.style.overflow;\r\n\t\t\ttable.style.overflow = \"hidden\";\r\n\t\t\tvar tableHeight = table.offsetHeight;\r\n\t\t\tfor (var count=0;count < arrCols.length;count++)\r\n\t\t\t{\r\n\t\t\t\tvar col = arrCols[count];\r\n\t\t\t\tvar resizer = this.__createResizer(count,tableHeight);\r\n\t\t\t\tcol.appendChild(resizer);\r\n\t\t\t\tthis.util.addStyleClass(col,\"nsResizableTableColumn\");\r\n\t\t\t\tthis.__addEventToResizer(resizer);\r\n\t\t\t\tthis.__arrResizer.push(resizer);\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSResizableTable.prototype.__createResizer = function(colIndex,height)\r\n\t{\r\n\t\tvar doc = this.__doc || this.__dom.doc;\r\n\t\tvar id = this.__getID() + \"_col\" + colIndex;\r\n\t\tvar resizer = this.util.createDiv(id,\"nsColumnResizer\",doc);\r\n\t\tresizer.style.height = height + \"px\";\r\n\t\treturn resizer;\r\n\t};\r\n\t\r\n\tNSResizableTable.prototype.__addEventToResizer = function(resizer)\r\n\t{\r\n\t\tvar self = this;\r\n\t\tvar resizeEventHandler = function(event)\r\n\t\t{\r\n\t\t\tevent = self.util.getEvent(event);\r\n\t\t\tevent.stopPropagation();\r\n\t\t\tevent.preventDefault();\r\n\t\t\tevent.stopImmediatePropagation();\r\n\t\t};\r\n\t\tthis.util.addEvent(resizer,\"mousedown touchstart\",this.__resizerMouseDownHandler.bind(this,resizer));\r\n\t\tthis.util.addEvent(resizer,\"click\",resizeEventHandler);\r\n\t\tthis.util.addEvent(resizer,\"dblclick\",resizeEventHandler);\r\n\t\tthis.util.addEvent(resizer,\"mouseover\",this.__resizerMouseOverHandler.bind(this,resizer));\r\n\t\tthis.util.addEvent(resizer,\"mouseout\",this.__resizerMouseOutHandler.bind(this,resizer));\r\n\t};\r\n\t\r\n\tNSResizableTable.prototype.__resizerMouseDownHandler = function(resizer,event)\r\n\t{\r\n\t\tevent = this.util.getEvent(event);\r\n\t\tvar doc = this.__doc || this.__dom.doc;\r\n\t\tresizer = event.target;\r\n\t\tthis.__objDrag = {dragging: true,resizer: resizer};\r\n\t\tthis.__objDrag.resizerMouseMove = this.__resizerMouseOverHandler.bind(this,resizer);\r\n\t\tthis.__objDrag.resizerMouseUp = this.__resizerMouseOutHandler.bind(this,resizer);\r\n\t\tthis.util.addEvent(resizer,\"mouseover\",this.__objDrag.resizerMouseMove);\r\n\t\tthis.util.addEvent(resizer,\"mouseout\",this.__objDrag.resizerMouseUp);\r\n\t\tthis.__objDrag.docMouseMove = this.__docMouseMoveHandler.bind(this,resizer);\r\n\t\tthis.__objDrag.docMouseUp = this.__docMouseUpHandler.bind(this,resizer);\r\n\t\tthis.util.addEvent(doc,\"mousemove touchmove\",this.__objDrag.docMouseMove);\r\n\t\tthis.util.addEvent(doc,\"mouseup\",this.__objDrag.docMouseUp);\r\n\t\tthis.__objDrag.currentColumn = event.target.parentElement;\r\n\t\tthis.__objDrag.nextColumn = this.__objDrag.currentColumn.nextElementSibling;\r\n\t\tthis.__objDrag.pageX = event.pageX; \r\n\t\tvar padding = this.__getPaddingDiff(this.__objDrag.currentColumn);\r\n\t\tthis.__objDrag.currentColumnWidth = this.__objDrag.currentColumn.offsetWidth - padding;\r\n\t\tif (this.__objDrag.nextColumn)\r\n\t\t{\r\n\t\t\tthis.__objDrag.nextColumnWidth = this.__objDrag.nextColumn.offsetWidth - padding;\r\n\t\t}\r\n\t\tvar item = {column: this.__objDrag.currentColumn,index: this.__objDrag.currentColumn.cellIndex};\r\n\t\tthis.__dispatchEvent(NSResizableTable.COLUMN_RESIZING_START,item,item);\r\n\t};\r\n\t\r\n\tNSResizableTable.prototype.__resizerMouseOverHandler = function(resizer,event)\r\n\t{\r\n\t\t//if(this.__objDrag && this.__objDrag.dragging)\r\n\t\t//{\r\n\t\t\tevent = this.util.getEvent(event);\r\n\t\t\tthis.util.addStyleClass(event.target,\"nsColumnResizerMoving\");\r\n\t\t//}\r\n\t};\r\n\t\r\n\tNSResizableTable.prototype.__resizerMouseOutHandler = function(resizer,event)\r\n\t{\r\n\t\t//if(this.__objDrag && this.__objDrag.dragging)\r\n\t\t//{\r\n\t\t\tevent = this.util.getEvent(event);\r\n\t\t\tthis.util.removeStyleClass(event.target,\"nsColumnResizerMoving\");\r\n\t\t//}\r\n\t};\r\n\t\r\n\tNSResizableTable.prototype.__docMouseMoveHandler = function(resizer,event)\r\n\t{\r\n\t\tif(this.__objDrag && this.__objDrag.dragging)\r\n\t\t{\r\n\t\t\tevent = this.util.getEvent(event);\r\n\t\t\tif(this.__objDrag.currentColumn)\r\n\t\t\t{\r\n\t\t\t\tthis.util.makeBodyUnselectable();\r\n\t\t\t\tvar diffX = event.pageX - this.__objDrag.pageX;\r\n\t\t\t\tif(this.__objDrag.nextColumn)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__objDrag.nextColumn.style.width = (this.__objDrag.nextColumnWidth - diffX) + \"px\";\r\n\t\t\t\t}\r\n\t\t\t\tthis.__objDrag.currentColumn.style.width = (this.__objDrag.currentColumnWidth + diffX) + \"px\";\r\n\t\t\t\tvar item = {column: this.__objDrag.currentColumn,index: this.__objDrag.currentColumn.cellIndex};\r\n\t\t\t\tthis.__dispatchEvent(NSResizableTable.COLUMN_RESIZING,item,item);\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSResizableTable.prototype.__docMouseUpHandler = function(resizer,event)\r\n\t{\r\n\t\tif(this.__objDrag)\r\n\t\t{\r\n\t\t\tevent = this.util.getEvent(event);\r\n\t\t\tvar doc = this.__doc || this.__dom.doc;\r\n\t\t\tthis.util.removeEvent(this.__objDrag.resizer,\"mouseover\",this.__objDrag.resizerMouseMove);\r\n\t\t\tthis.util.removeEvent(this.__objDrag.resizer,\"mouseout\",this.__objDrag.resizerMouseUp);\r\n\t\t\tthis.util.removeEvent(doc,\"mousemove touchmove\",this.__objDrag.docMouseMove);\r\n\t\t\tthis.util.removeEvent(doc,\"mouseup\",this.__objDrag.docMouseUp);\r\n\t\t\tthis.util.makeBodySelectable();\r\n\t\t\tvar currentColumn = this.__objDrag.currentColumn;\r\n\t\t\tthis.__objDrag = null;\r\n\t\t\tevent.stopImmediatePropagation();\r\n\t\t\tvar item = {column: currentColumn,index: currentColumn.cellIndex};\r\n\t\t\tthis.__dispatchEvent(NSResizableTable.COLUMN_RESIZING_END,item,item);\r\n\t\t}\r\n\t};\r\n\t\r\n\t/*********************************Start of Util Function*******************************/\r\n\tNSResizableTable.prototype.__getID = function()\r\n\t{\r\n\t\tif(!this.__id)\r\n\t\t{\r\n\t\t\tthis.__id = \"compResizableTable\" + this.util.getUniqueId();\r\n\t\t}\r\n\t\treturn this.__id;\r\n\t};\r\n\t\r\n\tNSResizableTable.prototype.__getPaddingDiff = function(column)\r\n\t{\r\n\t\tif (this.util.getStyleValue(column,\"box-sizing\") == \"border-box\")\r\n\t\t{\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\tvar padLeft = this.util.getStyleValue(column,\"padding-left\");\r\n\t\tvar padRight = this.util.getStyleValue(column,\"padding-right\");\r\n\t\treturn (parseInt(padLeft) + parseInt(padRight));\r\n\t };\r\n\t \r\n\t NSResizableTable.prototype.__dispatchEvent = function(eventType,data,param,bubbles,cancelable)\r\n\t {\r\n\t\tthis.util.dispatchEvent(this.__table,eventType,data,param,bubbles,cancelable);\r\n\t };\r\n\t/*********************************End of Util Function*******************************/\r\n\t\r\n\tNSResizableTable.prototype.destroy = function()\r\n\t{\r\n\t\tfor(var key in this.__origTableProp)\r\n\t\t{\r\n\t\t\tthis.__table.style[key] = this.__origTableProp[key];\r\n\t\t}\r\n\t\tthis.__origTableProp = {};\r\n\t};\r\n\t\r\n\tNSResizableTable.COLUMN_RESIZING_START = \"columnResizingStart\";\r\n\tNSResizableTable.COLUMN_RESIZING = \"columnResizing\";\r\n\tNSResizableTable.COLUMN_RESIZING_END = \"columnResizingEnd\";\r\n\t\r\n\treturn NSResizableTable;\r\n})();\r\nnsModuleExport(this,\"NSResizableTable\",NSResizableTable);var NSTablePicker = (function()\r\n{\r\n\tvar NSTablePicker = function(setting)\r\n\t{\r\n\t\tvar self = this;\r\n\t\tvar config = {};\r\n\t    \r\n\t    var util = null;\r\n\t    var win = null;\r\n\t\tvar doc = null;\r\n\t\tvar deviceSupport = null;\r\n\t\tvar parent = null;\r\n\t    var container = null;\r\n\t    var tblContainerCon = null;\r\n\t    var tblContainer = null;\r\n\t    var labelContainerCon = null;\r\n\t    var labelContainer = null;\r\n\t    var arrCells = [];\r\n\t    var strDefaultStyle = \"\";\r\n\t    var nsPopUp = null;\r\n\t    var id = null;\r\n\t\t\r\n\t\tvar initialize = function()\r\n\t\t{\r\n\t\t\tif(!setting)\r\n\t\t\t{\r\n\t\t\t\tsetting = {};\r\n\t\t\t}\r\n\t\t\tutil = new NSUtil();\r\n\t\t\tvar obj = util.getDomVariables();\r\n    \t\twin = obj.win;\r\n    \t\tdoc = obj.doc;\r\n    \t\tdeviceSupport = util.getSupportedEvents();\r\n\t\t\tconfig = {\r\n\t\t\t    context: setting[\"context\"] || win,\r\n\t\t\t    isPopUp: Boolean.parse(setting[\"isPopUp\"]),\r\n\t\t\t    popUpPos: setting[\"popUpPos\"] || util.POS_BOTTOMRIGHT,\r\n\t\t\t    trigger: setting[\"trigger\"],\r\n\t\t\t    triggerEvent: setting[\"triggerEvent\"] || \"click\",\r\n\t\t\t    closeOnOutsideClick: util.isUndefinedOrNull(setting[\"closeOnOutsideClick\"]) ? true : Boolean.parse(setting[\"closeOnOutsideClick\"]),\r\n\t\t\t    element: setting[\"element\"],\r\n\t\t\t\twidth: setting[\"width\"] || 200,\r\n\t\t\t\theight: setting[\"height\"] || 200,\r\n\t\t\t\tcellWidth: setting[\"cellWidth\"] || 20,\r\n\t\t\t\tcellHeight: setting[\"cellHeight\"] || 20,\r\n\t\t\t\trowCount: setting[\"rowCount\"] || 10,\r\n\t\t\t\tcolumnCount: setting[\"columnCount\"] || 10,\r\n\t\t\t\tenableShowDimension: util.isUndefinedOrNull(setting[\"enableShowDimension\"]) ? true : Boolean.parse(setting[\"enableShowDimension\"]),\r\n\t\t\t\ttheme: setting[\"theme\"] || \"White\",\r\n\t\t\t\tcellMouseOverCallback: setting[\"cellMouseOverCallback\"],\r\n\t\t\t\tcellMouseOutCallback: setting[\"cellMouseOutCallback\"],\r\n\t\t\t\tcellClickCallback: setting[\"cellClickCallback\"],\r\n\t\t\t\tpopUpOpenCallback: setting[\"popUpOpenCallback\"],\r\n\t\t\t\tpopUpCloseCallback: setting[\"popUpCloseCallback\"],\r\n\t\t\t};\r\n\t\t\tif (!config.isPopUp && !config.element) \r\n\t\t\t{\r\n\t\t\t\tutil.throwNSError(\"NSTablePicker\",\"Element in setting is missing\");\r\n\t        }\r\n\t   \t\tif(!setting.customClass)\r\n    \t\t{\r\n    \t\t\tsetting.customClass = {};\r\n    \t\t}\r\n    \t\tconfig.customClass = {\r\n    \t\t\t\tcontainer:setting.customClass[\"container\"],\r\n    \t\t\t\ttableContainer:setting.customClass[\"tableContainer\"],\r\n    \t\t\t\ttable:setting.customClass[\"table\"],\r\n    \t\t\t\trowContainer:setting.customClass[\"rowContainer\"],\r\n    \t\t\t\trow:setting.customClass[\"row\"],\r\n    \t\t\t\tcellContainer:setting.customClass[\"cellContainer\"],\r\n    \t\t\t\tcell:setting.customClass[\"cell\"],\r\n    \t\t\t\tlabelContainer:setting.customClass[\"labelContainer\"],\r\n    \t\t\t\tlabel:setting.customClass[\"label\"]\r\n    \t\t};\r\n\r\n\t\t\tcreateComponent();\r\n\t\t};\r\n\t\t\r\n\t\tvar createComponent = function()\r\n\t\t{\r\n\t\t\tif(container)\r\n\t\t\t{\r\n\t\t\t\tif(container.parentElement)\r\n\t\t\t\t{\r\n\t\t\t\t\tcontainer.parentElement.removeChild(container);\r\n\t\t\t\t}\r\n\t\t\t\tresetVars();\r\n\t\t\t}\r\n\t\t\tif(config.isPopUp)\r\n\t\t\t{\r\n\t\t\t\tvar popUpSetting = {type:\"div\",width:null,position:config.popUpPos,closeOnOutsideClick:config.closeOnOutsideClick\r\n\t\t\t\t\t\t\t\t\t,hideOrRemoveOnOutsideClick: \"hide\",width: \"auto\"};\r\n\t\t\t\tnsPopUp = new util.nsPopUp(popUpSetting);\r\n\t\t\t\tnsPopUp.create();\r\n\t\t\t\tparent = nsPopUp.getPopUp();\r\n\t\t\t\tif(config.trigger)\r\n\t\t\t\t{\r\n\t\t\t\t\tif(util.isElement(config.trigger))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tutil.addEvent(config.trigger,config.triggerEvent,handleTriggerEvent);\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\tutil.warning(\"NSTablePicker\",\"Trigger is not a element\");\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\tparent = config.element;\r\n\t\t\t}\r\n\t\t\tcontainer = util.createDiv(getID() + \"Container\",\"nsTablePicker\");\r\n\t\t\tparent.appendChild(container);\r\n\t\t\tsetTheme(config.theme);\r\n\t\t\tapplyCustomClass(container,\"container\");\r\n\t\t\tvar radius = util.getStyleValue(container, \"border-radius\", true);\r\n\t\t\tcreateTable(config.rowCount,config.columnCount);\r\n\t\t\tcreateLabel();\r\n\t\t\tif(!radius)\r\n\t\t\t{\r\n\t\t\t\tradius = 0;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tradius = util.getDimensionAsNumber(container,radius);\r\n\t\t\t}\r\n\t\t\tif(radius)\r\n\t\t\t{\r\n\t\t\t\tradius = parseInt(radius,10) * 2;\r\n\t\t\t}\r\n\t\t\tvar labelHeight = 0;\r\n\t\t\tif(labelContainerCon)\r\n\t\t\t{\r\n\t\t\t\tlabelHeight = labelContainerCon.offsetHeight;\r\n\t\t\t}\r\n\t\t\t//for Firefox\r\n\t\t\t//container.style.width = (config.width + radius) + \"px\";\r\n\t\t\t//container.style.height = (config.height + radius + labelHeight) + \"px\";\r\n\t\t\t/*var paddingLeft = util.getStyleValue(tblContainerCon, \"padding-left\", true);\r\n\t\t\tif(!paddingLeft)\r\n\t\t\t{\r\n\t\t\t\tpaddingLeft = 0;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tpaddingLeft = util.getDimensionAsNumber(tblContainerCon,paddingLeft);\r\n\t\t\t}\r\n\t\t\tvar paddingRight = util.getStyleValue(tblContainerCon, \"padding-right\", true);\r\n\t\t\tif(!paddingRight)\r\n\t\t\t{\r\n\t\t\t\tpaddingRight = 0;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tpaddingRight = util.getDimensionAsNumber(tblContainerCon,paddingRight);\r\n\t\t\t}\r\n\t\t\ttblContainerCon.style.width = (config.width + paddingLeft + paddingRight) + \"px\";*/\r\n\t\t\ttblContainerCon.style.height = (config.height) + \"px\";\r\n\t\t\t/*if(labelContainerCon)\r\n\t\t\t{\r\n\t\t\t\tvar orignalValue = parent.style.display;\r\n\t\t\t\tparent.style.display = \"block\";\r\n\t\t\t\ttblContainerCon.style.height = (container.offsetHeight - labelContainerCon.offsetHeight) + \"px\";\r\n\t\t\t\tparent.style.display = (orignalValue) ? orignalValue : \"\";\r\n\t\t\t}*/\r\n\t\t\tcalculateCellDimensions();\r\n\t\t};\r\n\t\t\r\n\t\tvar calculateCellDimensions = function()\r\n\t\t{\r\n\t\t\tif(!config.cellWidth || !config.cellHeight)\r\n\t\t\t{\r\n\t\t\t\tvar orignalValue = parent.style.display;\r\n\t\t\t\tparent.style.display = \"block\";\r\n\t\t\t\tif(!config.cellWidth)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar availableWidth = tblContainer.offsetWidth;\r\n\t\t\t\t\tconfig.cellWidth = availableWidth / config.columnCount;\r\n\t\t\t\t}\r\n\t\t\t\tif(!config.cellHeight)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar availableHeight = tblContainer.offsetHeight;\r\n\t\t\t\t\tconfig.cellHeight = availableHeight / config.rowCount;\r\n\t\t\t\t}\r\n\t\t\t\tparent.style.display = (orignalValue) ? orignalValue : \"\";\r\n\t\t\t}\r\n\t\t\tif(config.cellWidth && config.cellHeight)\r\n\t\t\t{\r\n\t\t\t\tvar id = getID() + \"Container\";\r\n\t\t\t\tutil.addCSSClassInDOM([\"#\" + id + \".nsTablePicker .nsTableCellContainer\"],[\"width:\" + config.cellWidth + \"px;height:\" + config.cellHeight + \"px;\"]);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tvar createLabel = function()\r\n\t\t{\r\n\t\t\tif(config.enableShowDimension)\r\n\t\t\t{\r\n\t\t\t\tlabelContainerCon = util.createDiv(null,\"nsTablePickerLblCon\");\r\n\t\t\t\tapplyCustomClass(labelContainerCon,\"labelContainer\");\r\n\t\t\t\tlabelContainer = util.createDiv(null,\"nsTablePickerLbl\");\r\n\t\t\t\tapplyCustomClass(labelContainer,\"label\");\r\n\t\t\t\tlabelContainerCon.appendChild(labelContainer);\r\n\t\t\t\tcontainer.appendChild(labelContainerCon);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tvar createTable = function(rowCount,colCount)\r\n\t\t{\r\n\t\t\ttblContainerCon = util.createDiv(null,\"nsTablePickerTblCon\");\r\n\t\t\tapplyCustomClass(tblContainerCon,\"tableContainer\");\r\n\t\t\ttblContainer = util.createDiv(null,\"nsTablePickerTbl\");\r\n\t\t\tfor(var rowIndex = 0;rowIndex < rowCount;rowIndex++)\r\n\t\t\t{\r\n\t\t\t\tvar rowCon = createRow(rowIndex,colCount);\r\n\t\t\t\ttblContainer.appendChild(rowCon);\r\n\t\t\t}\r\n\t\t\tapplyCustomClass(tblContainer,\"table\");\r\n\t\t\ttblContainerCon.appendChild(tblContainer);\r\n\t\t\tcontainer.appendChild(tblContainerCon);\r\n\t\t};\r\n\t\t\r\n\t\tvar createRow = function(rowIndex,colCount)\r\n\t\t{\r\n\t\t\tvar rowContainer = util.createDiv(null,\"nsTableRowContainer\");\r\n\t\t\trowContainer.setAttribute(\"ns-row-index\",rowIndex);\r\n\t\t\tapplyCustomClass(rowContainer,\"rowContainer\");\r\n\t\t\tvar row = util.createDiv(null,\"nsTableRow\");\r\n\t\t\tfor(var cellIndex = 0;cellIndex < colCount;cellIndex++)\r\n\t\t\t{\r\n\t\t\t\tvar cellCon = createCell(rowIndex,cellIndex,row);\r\n\t\t\t\trow.appendChild(cellCon);\r\n\t\t\t}\r\n\t\t\tapplyCustomClass(row,\"row\");\r\n\t\t\trowContainer.appendChild(row);\r\n\t\t\treturn rowContainer;\r\n\t\t};\r\n\t\t\r\n\t\tvar createCell = function(rowIndex,cellIndex,row)\r\n\t\t{\r\n\t\t\tvar cellContainer = util.createDiv(null,\"nsTableCellContainer\");\r\n\t\t\tcellContainer.setAttribute(\"ns-row-index\",rowIndex);\r\n\t\t\tcellContainer.setAttribute(\"ns-cell-index\",cellIndex);\r\n\t\t\tapplyCustomClass(cellContainer,\"cellContainer\");\r\n\t\t\tvar cell = util.createDiv(null,\"nsTableCell\");\r\n\t\t\tcellContainer.appendChild(cell);\r\n\t\t\tapplyCustomClass(cell,\"cell\");\r\n\t\t\tstrDefaultStyle = cell.className;\r\n\t\t\tutil.addEvent(cellContainer,\"mouseover\",cellMouseOverHandler.bind(null,cell,rowIndex,cellIndex));\r\n\t\t\tutil.addEvent(cellContainer,\"mouseout\",cellMouseOutHandler.bind(null,cell,rowIndex,cellIndex));\r\n\t\t\tutil.addEvent(cellContainer,\"click\",cellClickHandler.bind(null,cell,rowIndex,cellIndex));\r\n\t\t\tarrCells.push({rowIndex: rowIndex,cellIndex: cellIndex,row: row,cell: cell,cellContainer: cellContainer});\r\n\t\t\treturn cellContainer;\r\n\t\t};\r\n\t\t\r\n\t\tvar cellMouseOverHandler = function(cell,rowIndex,cellIndex,event)\r\n\t\t{\r\n\t\t\tevent = util.getEvent(event);\r\n\t\t\tif(config.cellMouseOverCallback)\r\n\t\t\t{\r\n\t\t\t\tconfig.cellMouseOverCallback(event,cell,rowIndex + 1,cellIndex + 1);\r\n\t\t\t}\r\n\t\t    if (event.target)\r\n\t\t    {\r\n\t\t    \tvar xPos = (cellIndex + 1) * config.width / config.columnCount;\r\n\t\t\t    var yPos = (rowIndex + 1) * config.height / config.rowCount;\r\n\t\t    }\r\n\t\t    renderCells(rowIndex,cellIndex);\r\n\t\t    refreshLabel(xPos,yPos,rowIndex,cellIndex);\r\n\t\t};\r\n\t\t\r\n\t\tvar cellMouseOutHandler = function(cell,rowIndex,cellIndex,event)\r\n\t\t{\r\n\t\t\tevent = util.getEvent(event);\r\n\t\t\tif(config.cellMouseOutCallback)\r\n\t\t\t{\r\n\t\t\t\tconfig.cellMouseOutCallback(event,cell,rowIndex + 1,cellIndex + 1);\r\n\t\t\t}\r\n\t\t\trenderCells(null,null);\r\n\t\t\trefreshLabel(0,0,null,null);\r\n\t\t};\r\n\t\t\r\n\t\tvar cellClickHandler = function(cell,rowIndex,cellIndex,event)\r\n\t\t{\r\n\t\t\tevent = util.getEvent(event);\r\n\t\t\tevent.preventDefault();\r\n\t\t\tif(config.cellClickCallback)\r\n\t\t\t{\r\n\t\t\t\tconfig.cellClickCallback(event,cell,rowIndex + 1,cellIndex + 1);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tvar renderCells = function(activeRowIndex,activeCellIndex)\r\n\t\t{\r\n\t\t\tfor(var cellCount = 0;cellCount < arrCells.length;cellCount++)\r\n\t\t\t{\r\n\t\t\t\tvar item = arrCells[cellCount];\r\n\t\t\t\tvar styleClass = strDefaultStyle;\r\n                if (item.rowIndex == activeRowIndex && item.cellIndex === activeCellIndex) \r\n                {\r\n                \tstyleClass += \" nsTableCellActive\";\r\n                } \r\n                else if (item.rowIndex <= activeRowIndex && item.cellIndex <= activeCellIndex) \r\n                {\r\n                \tstyleClass += \" nsTableCellSelected\";\r\n                } \r\n\r\n                /*if(item.rowIndex <= selectedRow && item.cellIndex <= selectedColumn) \r\n                {\r\n                  \tstyleClass += \" nsTableCellActive\";\r\n                }*/\r\n                item.cell.setAttribute(\"class\",styleClass);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tvar refreshLabel = function(xPos,yPos,activeRowIndex,activeCellIndex)\r\n\t\t{\r\n\t\t\tif(config.enableShowDimension)\r\n\t\t\t{\r\n\t\t\t\tif(activeRowIndex == null)\r\n\t\t\t\t{\r\n\t\t\t\t\tlabelContainer.innerHTML = \"\";\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tlabelContainer.innerHTML = (activeRowIndex + 1)  + \" x \" + (activeCellIndex + 1);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tvar applyCustomClass = function(element,type)\r\n    \t{\r\n    \t\tif(element && type && config.customClass[type])\r\n    \t\t{\r\n    \t\t\tutil.addStyleClass(element,config.customClass[type]);\r\n    \t\t}\r\n    \t};\r\n    \t\r\n    \tvar handleTriggerEvent= function(event)\r\n    \t{\r\n    \t\tif(nsPopUp)\r\n    \t\t{\r\n    \t\t\tevent = util.getEvent(event);\r\n    \t\t\tevent.stopPropagation();\r\n    \t\t\tif(nsPopUp.isOpen())\r\n    \t\t\t{\r\n    \t\t\t\tclose(event);\r\n    \t\t\t}\r\n    \t\t\telse\r\n    \t\t\t{\r\n    \t\t\t\topen(event);\r\n    \t\t\t}\r\n    \t\t}\r\n    \t};\r\n    \t\r\n    \tvar resetVars = function()\r\n    \t{\r\n    \t\tcontainer = null;\r\n\t\t\tarrCells = [];\r\n\t\t\tstrDefaultStyle = \"\";\r\n    \t};\r\n    \t\r\n    \tvar getID = function()\r\n    \t{\r\n    \t\tif(!id)\r\n    \t\t{\r\n    \t\t\tvar comp = config.isPopUp ? (config.trigger ? config.trigger : null) : config.element;\r\n    \t\t\tif(comp)\r\n    \t\t\t{\r\n    \t\t\t\tif(comp.hasAttribute(\"id\"))\r\n        \t\t\t{\r\n        \t\t\t\tid = comp.getAttribute(\"id\");\r\n        \t\t\t}\r\n        \t\t\telse if(comp.hasAttribute(\"name\"))\r\n        \t\t\t{\r\n        \t\t\t\tid = comp.getAttribute(\"name\");\r\n        \t\t\t}\r\n    \t\t\t}\r\n    \t\t\tif(!id)\r\n    \t\t\t{\r\n    \t\t\t\tid = \"comp\" + util.getUniqueId();\r\n    \t\t\t}\r\n    \t\t}\r\n    \t\treturn id;\r\n    \t};\r\n\t\t\r\n\t\tvar setTheme = function(theme) \r\n    \t{\r\n    \t\tif(container && config.theme)\r\n    \t\t{\r\n    \t\t\tutil.removeStyleClass(container,\"nsTablePicker\" + config.theme);\r\n    \t\t\tconfig.theme = theme;\r\n    \t\t\tutil.addStyleClass(container,\"nsTablePicker\" + config.theme);\r\n    \t\t}\r\n    \t};\r\n    \t\r\n    \tvar open = function(event) \r\n    \t{\r\n    \t\tif(nsPopUp)\r\n    \t\t{\r\n    \t\t\tnsPopUp.show();\r\n    \t\t\tif(config.trigger)\r\n    \t\t\t{\r\n    \t\t\t\tnsPopUp.placePopUp(config.trigger);\r\n    \t\t\t}\r\n    \t\t\telse if(event)\r\n    \t\t\t{\r\n    \t\t\t\tnsPopUp.placePopUp(event);\r\n    \t\t\t}\r\n    \t\t\tif(config.popUpOpenCallback)\r\n    \t\t\t{\r\n    \t\t\t\tconfig.popUpOpenCallback(event,self);\r\n    \t\t\t}\r\n    \t\t}\r\n    \t\telse\r\n    \t\t{\r\n    \t\t\tutil.warning(\"NSTablePicker\",\"PopUp is not enabled\");\r\n    \t\t}\r\n    \t};\r\n    \t\r\n    \tvar close = function(event) \r\n    \t{\r\n    \t\tif(nsPopUp)\r\n    \t\t{\r\n    \t\t\tnsPopUp.hide();\r\n    \t\t\tif(config.popUpCloseCallback)\r\n    \t\t\t{\r\n    \t\t\t\tconfig.popUpCloseCallback(event,self);\r\n    \t\t\t}\r\n    \t\t}\r\n    \t\telse\r\n    \t\t{\r\n    \t\t\tutil.warning(\"NSTablePicker\",\"PopUp is not enabled\");\r\n    \t\t}\r\n    \t};\r\n    \t\r\n    \tvar remove = function()\r\n    \t{\r\n    \t\tif(nsPopUp)\r\n    \t\t{\r\n    \t\t\tnsPopUp.remove();\r\n    \t\t\tnsPopUp = null;\r\n    \t\t}\r\n    \t\telse if(container)\r\n    \t\t{\r\n    \t\t\tif(container.parentElement)\r\n\t\t\t\t{\r\n\t\t\t\t\tcontainer.parentElement.removeChild(container);\r\n\t\t\t\t}\r\n    \t\t}\r\n    \t\tresetVars();\r\n    \t};\r\n    \t\r\n    \tvar isOpen = function() \r\n    \t{\r\n    \t\tif(nsPopUp)\r\n    \t\t{\r\n    \t\t\treturn nsPopUp.isOpen();\r\n    \t\t}\r\n    \t\treturn false;\r\n    \t};\r\n\t\t\r\n\t\tinitialize();\r\n\t\t\r\n\t\tself.setTheme = setTheme;\r\n\t\tself.open = open;\r\n\t\tself.close = close;\r\n\t\tself.remove = remove;\r\n\t\tself.isOpen = isOpen;\r\n\t};\r\n\t\r\n\treturn NSTablePicker;\r\n})();\r\nnsModuleExport(this,\"NSTablePicker\",NSTablePicker);\"use strict\"; \r\nvar NSTableUtil = (function()\r\n{\r\n\tfunction NSTableUtil(doc,win) \r\n\t{\t\t\r\n\t\tvar self = this;\r\n\t\tvar util = new NSUtil();\r\n\t\tvar dom = util.getDomVariables();\r\n\t\t\r\n\t\tthis.doc = doc || dom.doc;\r\n\t\tthis.win = win || dom.window;\r\n\t\t\r\n\t\tthis.getRowsCount = function(table) \r\n\t\t{\r\n\t        return table.rows.length;\r\n\t    };\r\n\t    \r\n\t    this.getColumnsCount = function(table) \r\n\t    {\r\n\t    \tvar arrFlatRows = getFlattenRows(table);\r\n\t        var colCount = arrFlatRows.reduce(function(total,cells,currentIndex,arr) \r\n\t        {\r\n\t            return Math.max(total, cells.length);\r\n\t        },0);\r\n\t        return colCount;\r\n\t    };\r\n\t    \r\n\t    //appendRow\r\n\t    this.insertRow = function(table,rowReference,isInsertBelow,callback) \r\n\t    {\r\n\t    \tvar arrRet = [];\r\n\t    \tvar row = null;\r\n\t        if (!rowReference) \r\n\t        {\r\n\t            var colCount = this.getColumnsCount(table);\r\n\t            row = this.doc.createElement(\"tr\");\r\n\t            for (var colIndex = 0;colIndex < colCount; colIndex++) \r\n\t            {\r\n\t            \tvar cell = this.doc.createElement(\"td\");\r\n\t            \tcallback && callback(cell,row,table,colIndex,rowReference,isInsertBelow);\r\n\t                row.appendChild(cell);\r\n\t                arrRet.push(cell);\r\n\t            }\r\n\t        }\r\n\t        else \r\n\t        {\r\n\t            row = rowReference.cloneNode(true);\r\n\t            var arrCells = rowReference.querySelectorAll(\"td,th\");\r\n\t            for (var colIndex = 0;colIndex < arrCells.length; colIndex++) \r\n\t            {\r\n\t            \tvar cell = arrCells[colIndex];\r\n\t            \tvar rowspan = cell.getAttribute(\"rowspan\");\r\n\t                if (rowspan && parseInt(rowspan, 10) > 1) \r\n\t                {\r\n\t                    var newRowSpan = parseInt(rowspan, 10) - 1;\r\n\t                    if(newRowSpan > 1)\r\n\t                    {\r\n\t                    \tcell.getAttribute(\"rowspan\",newRowSpan);\r\n\t                    }\r\n\t                }\r\n\t            }\r\n\t            arrCells = row.querySelectorAll(\"td,th\");\r\n\t            for (var colIndex = 0;colIndex < arrCells.length; colIndex++) \r\n\t            {\r\n\t            \tvar cell = arrCells[colIndex];\r\n\t            \tutil.removeAllChildren(cell);\r\n\t            \tcallback && callback(cell,row,table,colIndex,rowReference,isInsertBelow);\r\n\t                arrRet.push(cell);\r\n\t            }\r\n\t        }\r\n\t        if (isInsertBelow && rowReference && rowReference.nextSibling) \r\n\t        {\r\n\t            if(rowReference.parentNode)\r\n\t            {\r\n\t            \tvar parent = rowReference.parentNode;\r\n\t            \tparent.insertBefore(row,rowReference.nextSibling);\r\n\t            }\r\n\t                \r\n\t        }\r\n\t        else if (!isInsertBelow && rowReference) \r\n\t        {\r\n\t        \tif(rowReference.parentNode)\r\n\t            {\r\n\t            \tvar parent = rowReference.parentNode;\r\n\t            \tparent.insertBefore(row,rowReference);\r\n\t            }\r\n\t        }\r\n\t        else \r\n\t        {\r\n\t        \tvar ref = table;\r\n\t        \tif(table.tBodies && table.tBodies.length)\r\n\t        \t{\r\n\t        \t\tref = table.tBodies[0];\r\n\t        \t}\r\n\t        \tref.appendChild(row);\r\n\t        }\r\n\t        return {row: row,cells: arrRet};\r\n\t    };\r\n\t\t\r\n\t\tthis.removeRow = function(table,rowIndex,callback) \r\n\t\t{\r\n\t\t\tvar arrRet = [];\r\n\t\t\tvar arrFlatRows = getFlattenRows(table);\r\n\t\t\tvar row = table.rows[rowIndex];\r\n\t\t\tvar arrCells = arrFlatRows[rowIndex];\r\n\t\t\tfor(var colIndex = 0;colIndex < arrCells.length;colIndex++)\r\n\t\t\t{\r\n\t\t\t\tvar cell = arrCells[colIndex];\r\n\t\t\t\tvar dec = false;\r\n\t\t\t\tif (rowIndex - 1 >= 0 && arrFlatRows[rowIndex - 1][colIndex] == cell) \r\n\t\t\t\t{\r\n\t                dec = true;\r\n\t            }\r\n\t\t\t\telse if (arrFlatRows[rowIndex + 1] && arrFlatRows[rowIndex + 1][colIndex] === cell) \r\n\t\t\t\t{\r\n\t                if (cell.parentNode == row && cell.parentNode.nextSibling) \r\n\t                {\r\n\t                    dec = true;\r\n\t                    var nextCell = colIndex + 1;\r\n\t                    while (arrFlatRows[rowIndex + 1][nextCell] == cell) \r\n\t                    {\r\n\t                        nextCell++;\r\n\t                    }\r\n\t                    var nextRow = util.findNextNode(cell.parentNode, function(element) \r\n\t                    { \r\n\t                    \treturn util.isElementOfType(element,\"tr\"); \r\n\t                    },table,true);\r\n\t                    if (arrFlatRows[rowIndex + 1][nextCell]) \r\n\t                    {\r\n\t                        nextRow.insertBefore(cell,arrFlatRows[rowIndex + 1][nextCell]);\r\n\t                    }\r\n\t                    else \r\n\t                    {\r\n\t                        nextRow.appendChild(cell);\r\n\t                    }\r\n\t                }\r\n\t            }\r\n\t            else \r\n\t            {\r\n\t            \tcallback && callback(cell,row,table,colIndex,rowIndex);\r\n\t            \tremoveNode(cell);\r\n\t            \tarrRet.push(cell);\r\n\t            }\r\n\t\t\t\tif (dec && (cell.parentNode === row || cell !== arrFlatRows[rowIndex][colIndex - 1])) \r\n\t\t\t\t{\r\n\t                var rowSpan = cell.rowSpan;\r\n\t                if (rowSpan - 1 > 1) \r\n\t                {\r\n\t                    cell.setAttribute(\"rowspan\", (rowSpan - 1).toString());\r\n\t                }\r\n\t                else \r\n\t                {\r\n\t                    cell.removeAttribute(\"rowspan\");\r\n\t                }\r\n\t\t        }\r\n\t\t\t}\r\n\t\t\tremoveNode(row);\r\n\t\t\treturn {row: row,cells: arrRet};\r\n\t\t};\r\n\t\t\r\n\t\t//appendColumn\r\n\t\tthis.insertColumn = function(table,refIndex,isInsertAfter,callback)\r\n\t\t{\r\n\t\t\tvar arrRet = [];\r\n\t\t\tvar arrFlatRows = getFlattenRows(table);\r\n\t        if (util.isUndefinedOrNull(refIndex) || refIndex < 0) \r\n\t        {\r\n\t            refIndex = getColumnsCount(table) - 1;\r\n\t        }\r\n\t        for (var rowCount = 0;rowCount < arrFlatRows.length;rowCount++) \r\n\t        {\r\n\t            var cell = this.doc.createElement(\"td\");\r\n\t            var refCell = arrFlatRows[rowCount][refIndex];\r\n\t            var isAdded = false;\r\n\t            if (isInsertAfter) \r\n\t            {\r\n\t            \tvar newRefIndex = refIndex + 1;\r\n\t                if ((arrFlatRows[rowCount] && refCell && newRefIndex >= arrFlatRows[rowCount].length) || refCell !== arrFlatRows[rowCount][newRefIndex]) \r\n\t                {\r\n\t                \tvar parent = refCell.parentNode;\r\n\t                \tif(parent)\r\n\t                \t{\r\n\t                \t\tif (refCell.nextSibling) \r\n\t\t                    {\r\n\t                \t\t\tparent.insertBefore(cell,refCell.nextSibling);\r\n\t\t                    }\r\n\t\t                    else \r\n\t\t                    {\r\n\t\t                    \tparent.appendChild(cell);\r\n\t\t                    }\r\n\t                \t\tisAdded = true;\r\n\t                \t}\r\n\t                }\r\n\t            }\r\n\t            else \r\n\t            {\r\n\t            \tvar newRefIndex = refIndex - 1;\r\n\t                if (newRefIndex < 0 || (arrFlatRows[rowCount][refIndex] !== arrFlatRows[rowCount][newRefIndex] && arrFlatRows[rowCount][refIndex].parentNode)) \r\n\t                {\r\n\t                \tvar parent = refCell.parentNode;\r\n\t                \tif(parent)\r\n\t                \t{\r\n\t                \t\tparent.insertBefore(cell,arrFlatRows[rowCount][refIndex]);\r\n\t                \t\tisAdded = true;\r\n\t                \t}\r\n\t                }\r\n\t            }\r\n\t            if(isAdded)\r\n\t            {\r\n\t            \tcallback && callback(cell,table,refIndex,isInsertAfter);\r\n\t            \tarrRet.push(cell);\r\n\t            }\r\n\t            else \r\n\t            {\r\n\t            \tvar refCell = arrFlatRows[rowCount][refIndex];\r\n\t            \tvar colspan = refCell.getAttribute(\"colspan\");\r\n\t            \tcolspan = colspan ? parseInt(colspan,10) : 1;\r\n\t            \tcolspan++;\r\n\t            \trefCell.setAttribute(\"colspan\",colspan);\r\n\t            }\r\n\t        }\r\n\t        return arrRet;\r\n\t\t};\r\n\t\t\r\n\t\tthis.removeColumn = function(table,colIndex,callback)\r\n\t\t{\r\n\t\t\tvar arrRet = [];\r\n\t\t\tvar arrFlatRows = getFlattenRows(table);\r\n\t\t\tfor(var rowIndex = 0;rowIndex < arrFlatRows.length;rowIndex++)\r\n\t\t\t{\r\n\t\t\t\tvar arrCells = arrFlatRows[rowIndex];\r\n\t\t\t\tvar cell = arrCells[colIndex];\r\n\t\t\t\tvar dec = false;\r\n\t\t\t\tif ((colIndex - 1) >= 0 && arrFlatRows[rowIndex][colIndex - 1] == cell) \r\n\t\t\t\t{\r\n\t                dec = true;\r\n\t            }\r\n\t            else if ((colIndex + 1) < arrCells.length && arrFlatRows[rowIndex][colIndex + 1] == cell) \r\n\t            {\r\n\t                dec = true;\r\n\t            }\r\n\t            else \r\n\t            {\r\n\t            \tcallback && callback(cell,table,colIndex);\r\n\t            \tremoveNode(cell);\r\n\t            \tarrRet.push(cell);\r\n\t            }\r\n\t\t\t\tif (dec && (rowIndex - 1 < 0 || cell !== arrFlatRows[rowIndex - 1][colIndex])) \r\n\t\t\t\t{\r\n\t                var colspan = cell.colSpan;\r\n\t                colspan = (colspan - 1) > 1 ? (colspan - 1) : null;\r\n\t                if(colspan)\r\n\t                {\r\n\t                \tcell.setAttribute(\"colspan\",colspan);\r\n\t                }\r\n\t            }\r\n\t\t\t}\r\n\t\t\treturn arrRet;\r\n\t\t};\r\n\t\t\r\n\t\t//splitVertical\r\n\t\tthis.splitCellsVertical = function(arrCells,table)\r\n\t\t{\r\n\t\t\tfor(var count = 0;count < arrCells.length;count++)\r\n\t\t\t{\r\n\t\t\t\tthis.splitCellVertical(arrCells[count],table);\r\n\t\t\t}\r\n\t\t\t//Table.normalizeTable(table);\r\n\t\t};\r\n\t\t\r\n\t\tthis.splitCellVertical = function(cell,table)\r\n\t\t{\r\n\t\t\tvar objCell = getCoordinates(table,cell);\r\n\t\t\t var objProp = {};\r\n            if (cell.colSpan < 2) \r\n            {\r\n            \tgetFlattenRows(table, function(paramCell,newRowIndex,newColIndex,colSpan,rowSpan) \r\n                {\r\n                    if (objCell.rowIndex != newRowIndex && objCell.colIndex == newColIndex && paramCell != cell) \r\n                    {\r\n                       storeProperties(paramCell,\"colspan\",paramCell.colSpan + 1, objProp);\r\n                    }\r\n                    return true;\r\n                });\r\n            }\r\n            else \r\n            {\r\n               storeProperties(cell,\"colspan\",cell.colSpan - 1,objProp);\r\n            }\r\n            var newCell = this.doc.createElement(\"td\");\r\n\t\t\tvar br = this.doc.createElement(\"br\");\r\n            newCell.appendChild(br);\r\n            if (cell.rowSpan > 1) \r\n            {\r\n               storeProperties(newCell,\"rowspan\",cell.rowSpan,objProp);\r\n            }\r\n            var cellWidth = cell.offsetWidth;\r\n            util.insertAfterElement(cell,newCell);\r\n            var calcWidth = cellWidth / table.offsetWidth / 2;\r\n            storeProperties(cell,\"width\", (calcWidth * 100).toFixed(10) + '%', objProp);\r\n            storeProperties(newCell,\"width\", (calcWidth * 100).toFixed(10) + '%', objProp);\r\n            executeProperties(objProp);\r\n            //instance(jodit).removeSelection(cell);\r\n\t\t};\r\n\t\t\r\n\t\t//splitHorizontal\r\n\t\tthis.splitCellsHorizontal = function(arrCells,table)\r\n\t\t{\r\n\t\t\tfor(var count = 0;count < arrCells.length;count++)\r\n\t\t\t{\r\n\t\t\t\tthis.splitCellHorizontal(arrCells[count],table);\r\n\t\t\t}\r\n\t\t\t//Table.normalizeTable(table);\r\n\t\t};\r\n\t\t\r\n\t\tthis.splitCellHorizontal = function(cell,table)\r\n\t\t{\r\n\t\t\tvar newCell = this.doc.createElement(\"td\");\r\n\t\t\tvar br = this.doc.createElement(\"br\");\r\n            newCell.appendChild(br);\r\n            var objCell = getCoordinates(table,cell);\r\n            var objProp = {};\r\n            if (cell.rowSpan < 2) \r\n            {\r\n            \tvar row = util.findParent(cell,\"tr\");\r\n            \tvar newRow = this.doc.createElement(\"tr\");\r\n                getFlattenRows(table, function(paramCell,newRowIndex,newColIndex,colSpan,rowSpan) \r\n                {\r\n                    if (objCell.rowIndex == newRowIndex && objCell.colIndex != newColIndex && paramCell !== cell) \r\n                    {\r\n                    \tstoreProperties(paramCell,\"rowspan\",paramCell.rowSpan + 1,objProp);\r\n                    }\r\n                    return true;\r\n                });\r\n                util.insertAfterElement(row,newRow);\r\n                newRow.appendChild(newCell);\r\n            }\r\n            else \r\n            {\r\n            \tvar parentRow = null;\r\n                var afterCell = null;\r\n            \tstoreProperties(cell,\"rowspan\",cell.rowSpan - 1,objProp);\r\n                getFlattenRows(table, function(paramCell,newRowIndex,newColIndex,colSpan,rowSpan) \r\n                {\r\n                    if (newRowIndex > objCell.rowIndex && newRowIndex < objCell.rowIndex + cell.rowSpan \r\n                    \t&& objCell.colIndex > newColIndex && cell.parentNode.rowIndex == newRowIndex) \r\n                    {\r\n                    \tafterCell = paramCell;\r\n                    }\r\n                    if (objCell.rowIndex < newRowIndex && paramCell === cell) \r\n                    {\r\n                    \tparentRow = table.rows[newRowIndex];\r\n                    }\r\n                    return true;\r\n                });\r\n                if (afterCell) \r\n                {\r\n                \tutil.insertAfterElement(afterCell,newCell);\r\n                }\r\n                else \r\n                {\r\n                \tparentRow.insertBefore(newCell,parentRow.firstChild);\r\n                }\r\n            }\r\n            if (cell.colSpan > 1) \r\n            {\r\n            \tstoreProperties(newCell,\"colspan\",cell.colSpan,objProp);\r\n            }\r\n            executeProperties(objProp);\r\n            //instance(jodit).removeSelection(cell);\r\n\t\t};\r\n\t\t\r\n\t\t//__mark\r\n\t\tvar storeProperties = function(cell,prop,propValue,objProp)\r\n\t\t{\r\n\t\t\tvar cellID = cell.getAttribute(\"data-cell-util-id\");\r\n\t\t\tif(!cellID)\r\n\t\t\t{\r\n\t\t\t\tcellID = util.getUniqueId();\r\n\t\t\t\tcell.setAttribute(\"data-cell-util-id\",cellID);\r\n\t\t\t}\r\n\t\t\tif (!objProp[cellID]) \r\n\t\t\t{\r\n\t\t\t\tobjProp[cellID] = {cell: cell,objCellProps: {}};\r\n\t        }\r\n\t\t\tobjProp[cellID].objCellProps[prop] = propValue;\r\n\t\t};\r\n\t\t\r\n\t\t//__unmark\r\n\t\tvar executeProperties = function(objProp)\r\n\t\t{\r\n\t\t\tfor(var cellID in objProp)\r\n\t\t\t{\r\n\t\t\t\tvar cell = objProp[cellID].cell;\r\n\t\t\t\tvar objCellProps = objProp[cellID].objCellProps;\r\n\t\t\t\tfor(var prop in objCellProps)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar propValue =  objCellProps[prop];\r\n\t\t\t\t\tswitch(prop) \r\n\t\t\t\t\t{\r\n\t                    case \"remove\":\r\n\t                    \tremoveNode(cell);\r\n\t                    break;\r\n\t                    case \"rowspan\":\r\n\t                        (propValue > 1) ? cell.setAttribute(\"rowspan\",propValue) : cell.removeAttribute(\"rowspan\");\r\n\t                    break;\r\n\t                    case \"colspan\":\r\n\t                    \t(propValue > 1) ? cell.setAttribute(\"colspan\",propValue) : cell.removeAttribute(\"colspan\");\r\n\t                    break;\r\n\t                    case \"width\":\r\n\t                        cell.style.width = propValue;\r\n\t                    break;\r\n\t                }\r\n\t\t\t\t}\r\n\t\t\t\tcell.removeAttribute(\"data-cell-util-id\");\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\t//formalCoordinate\r\n\t\tvar getCoordinates = function(table,cell,isMax)\r\n\t\t{\r\n\t\t\tisMax = Boolean.parse(isMax);\r\n\t\t\tvar objRet = {rowIndex: 0,colIndex: 0,width: 1,height: 1};\r\n\t\t\tvar callback = function(paramCell,newRowIndex,newColIndex,colSpan,rowSpan)\r\n\t\t\t{\r\n\t\t\t\tif (cell === paramCell) \r\n\t            {\r\n\t\t\t\t\tobjRet.rowIndex = newRowIndex;\r\n\t\t\t\t\tobjRet.colIndex = newColIndex;\r\n\t\t\t\t\tobjRet.width = colSpan || 1;\r\n\t\t\t\t\tobjRet.height = rowSpan || 1;\r\n\t                if (isMax) \r\n\t                {\r\n\t                \tobjRet.rowIndex += (rowSpan || 1) - 1;\r\n\t                \tobjRet.colIndex += (colSpan || 1) - 1;\r\n\t                }\r\n\t                return false;\r\n\t            }\r\n\t\t\t\treturn true;\r\n\t\t\t};\r\n\t        getFlattenRows(table,callback);\r\n\t        return objRet;\r\n\t\t};\r\n\t\t\r\n\t\t//formalMatrix\r\n\t\t//returns rows and cells flattening considering colspan's and rowspan's\r\n\t\t// we don't need to handle hidden rows or width = 0 rows as rowIndex will handle it\r\n\t\tvar getFlattenRows = function(table,callback) \r\n\t\t{\r\n\t        var arrFlatRows = [[]];\r\n\t        if(table && table.rows)\r\n\t        {\r\n\t        \tvar arrRows = (table.rows.length) ? table.rows : Array.prototype.slice.call(table.rows);\r\n\t        \tfor(var rowCount = 0; rowCount < arrRows.length; rowCount++) \r\n\t        \t{\r\n\t        \t\tvar arrCells = (arrRows[rowCount].cells.length) ? arrRows[rowCount].cells : Array.prototype.slice.call(arrRows[rowCount].cells);\r\n\t                for(var colCount = 0; colCount < arrCells.length; colCount++) \r\n\t                {\r\n\t                \tvar arrRowsTemp = getFlattenCells(arrFlatRows,table,arrCells[colCount],rowCount,callback);\r\n\t                \tif(!arrRowsTemp)\r\n\t                \t{\r\n\t                \t\treturn arrFlatRows;\r\n\t                \t}\r\n\t                \tarrFlatRows = arrRowsTemp;\r\n\t                \t\r\n\t                }\r\n\t        \t}\r\n\t        }\r\n\t        return arrFlatRows;\r\n\t    };\r\n\t    \r\n\t    var getFlattenCells = function(arrRows,table,cell,rowIndex,callback) \r\n\t\t{\r\n\t    \tif(!arrRows[rowIndex])\r\n\t    \t{\r\n\t    \t\tarrRows[rowIndex] = [];\r\n\t    \t}\r\n\t    \tvar colSpan = cell.colSpan;\r\n\t    \tvar rowSpan = cell.rowSpan;\r\n\t    \tvar colIndex = 0;\r\n\t    \twhile(arrRows[rowIndex][colIndex]) \r\n\t    \t{\r\n\t    \t\tcolIndex++;\r\n\t        }\r\n\t    \tfor(var rowCount = 0; rowCount < rowSpan; rowCount++) \r\n\t    \t{\r\n\t            for(var colCount = 0; colCount < colSpan; colCount++) \r\n\t            {\r\n\t                if (!arrRows[rowIndex + rowCount]) \r\n\t                {\r\n\t                \tarrRows[rowIndex + rowCount] = [];\r\n\t                }\r\n\t                var newRowIndex = rowIndex + rowCount;\r\n\t                var newColIndex = colIndex + colCount;\r\n\t                if (callback) \r\n\t                {\r\n\t                \tvar value = callback(cell,newRowIndex,newColIndex,colSpan,rowSpan);\r\n\t                \tif(!value)\r\n\t                \t{\r\n\t                \t\treturn null;\r\n\t                \t}\r\n\t                }\r\n\t                arrRows[newRowIndex][newColIndex] = cell;\r\n\t            }\r\n\t        }\r\n\t    \treturn arrRows;\r\n\t\t};\r\n\t\t\r\n\t\tvar removeNode = function(node)\r\n\t\t{\r\n\t\t\tif (node && node.parentNode)\r\n\t    \t{\r\n\t    \t\tnode.parentNode.removeChild(node);\r\n\t    \t}\r\n\t\t};\r\n\t};\r\n\t\r\n\treturn NSTableUtil;\r\n})();\r\nnsModuleExport(this,\"NSTableUtil\",NSTableUtil); var NSEditorUtil = (function()\r\n{\r\n\tvar NSEditorUtil = function(nsEditor)\r\n\t{\r\n    \tthis.__nsEditor = nsEditor;\r\n\t\tthis.util = nsEditor.util;\r\n\t\tthis.selection = nsEditor.__selection;\r\n\t\t\r\n\t\tthis.REGEX_BLOCK = /^(PRE|DIV|P|LI|H[1-6]|BLOCKQUOTE|TD|TH|TABLE|BODY|HTML|FIGCAPTION|FIGURE|DT|DD)$/i;\r\n\t\tthis.REGEX_KEY_REMOVAL_TAGS = /^(IMG|BR|IFRAME|SCRIPT|INPUT|TEXTAREA|HR)$/i;\r\n\t\tthis.REGEX_EMPTY_TAGS = /^(IMG|BR|IFRAME|SCRIPT|INPUT|TEXTAREA|HR|TABLE)$/i;\r\n\t\tthis.SPACE_REG_EXP  = /[\\s\\n\\t\\r\\uFEFF\\u200b]+/g;\r\n\t\tthis.SPACE_REG_EXP_START = /^[\\s\\n\\t\\r\\uFEFF\\u200b]+/g;\r\n\t\tthis.SPACE_REG_EXP_END = /[\\s\\n\\t\\r\\uFEFF\\u200b]+$/g;\r\n\t\tthis.INVISIBLE_SPACE =  '\\uFEFF';\r\n\t\tthis.INVISIBLE_SPACE_REG_EXP =  /[\\uFEFF]/g;\r\n\r\n\t\t\r\n\t\tthis.ZERO_WIDTH_SPACE = String.fromCharCode(8203),\r\n\t\t\r\n\t\t//isOrContains\r\n\t\tthis.isExistsInsideEditor = function(node)\r\n\t\t{\r\n\t\t\tvar textArea = this.__nsEditor.__getTextArea();\r\n    \t\tvar parent = this.util.findParentByCallback(node,function(paramElement){\r\n\t\t\t\treturn paramElement === textArea || (paramElement && paramElement.parentNode === textArea);\r\n\t\t\t},textArea);\r\n    \t\treturn !this.util.isUndefinedOrNull(parent);\r\n\t\t};\r\n\t\t\r\n\t\t//closest\r\n\t\tthis.getClosestElement = function(element,tags,root)\r\n\t\t{\r\n\t\t\tvar condition;\r\n\t        if (typeof tags === 'function') \r\n\t        {\r\n\t            condition = tags;\r\n\t        }\r\n\t        else if (tags instanceof RegExp) \r\n\t        {\r\n\t            condition = function (tag) \r\n\t            { \r\n\t            \treturn tag && tags.test(tag.nodeName); \r\n\t            };\r\n\t        }\r\n\t        else \r\n\t        {\r\n\t            condition = function (tag) \r\n\t            {\r\n\t                return tag && new RegExp('^(' + tags + ')$', 'i').test(tag.nodeName);\r\n\t            };\r\n\t        }\r\n\t        return this.util.findParentByCallback(element, condition, root);\r\n\t\t};\r\n\t\t\r\n\t\tthis.isNode = function(element, win) \r\n\t\t{\r\n\t        if (!element) \r\n\t        {\r\n\t            return false;\r\n\t        }\r\n\t        if(!win)\r\n\t        {\r\n\t        \twin = this.__nsEditor.__getWindow();\r\n\t        }\r\n\t        if (typeof win === 'object' && win && (typeof win.Node === 'function' || typeof win.Node === 'object')) \r\n\t        {\r\n\t            return element instanceof win.Node;\r\n\t        }\r\n\t        return false;\r\n\t    };\r\n\t\t\r\n\t\tthis.isBlock = function(element, win) \r\n\t\t{\r\n\t        if(element && typeof element === \"object\")\r\n\t        {\r\n\t        \tvar isNode = this.isNode(element, win);\r\n\t        \tvar isBlock = this.REGEX_BLOCK.test(element.nodeName);\r\n\t        \tif(isNode && !isBlock)\r\n\t        \t{\r\n\t        \t\tvar display = this.util.getStyleValue(element,\"display\");\r\n\t        \t\tif(display && display == \"block\")\r\n\t        \t\t{\r\n\t        \t\t\tisBlock = true;\r\n\t        \t\t}\r\n\t        \t}\r\n\t        \tif(isNode && isBlock)\r\n\t        \t{\r\n\t        \t\treturn true;\r\n\t        \t}\r\n\t        }\r\n\t        return false; \r\n\t    };\r\n\t    \r\n\t    //elementIsBlock\r\n\t    this.isTagBlock = function(tag) \r\n\t\t{\r\n\t    \t(tag && this.REGEX_BLOCK.test(tag));\r\n\t\t};\r\n\t    \r\n\t    this.isTable = function(element, win) \r\n\t    {\r\n\t        return this.isNode(element, win) && /^(TABLE|THEAD|TBODY|TR|TH|TD)$/i.test(typeof element === 'string' ? element : element.nodeName);\r\n\t    }\r\n\t\t\r\n\t    this.isCell = function(element, win) \r\n\t    {\r\n\t    \treturn this.isNode(element, win) && /^(td|th)$/i.test(typeof element === 'string' ? element : element.nodeName);\r\n\t\t};\r\n\t\t\r\n\t\tthis.isImage = function(element, win) \r\n\t\t{\r\n\t\t    return this.isNode(element, win) && /^(img|svg|picture|canvas)$/i.test(typeof element === 'string' ? element : element.nodeName);\r\n\t\t};\r\n\t\t\r\n\t\t//isMediaComponent\r\n\t    this.isCustomMedia = function(element)\r\n\t    {\r\n\t    \treturn element && (/nsEditorMediaContainerContainer/.test(element.className));\r\n\t    };\r\n\t    \r\n\t    //isComponent\r\n\t    this.isCustomMediaOrTable = function(element) \r\n\t    {\r\n\t        return element && (this.isCustomMedia(element) || /^(TABLE|HR)$/.test(element.nodeName));\r\n\t    };\r\n\r\n\t    this.isFormatElement = function(element) \r\n\t    {\r\n\t    \treturn element && element.nodeType == 1 && /^(P|DIV|H[1-6]|PRE|LI|TH|TD)$/i.test(element.nodeName) && !this.isCustomMediaOrTable(element) && !this.containsNode(element,\"div\");\r\n\t    };\r\n\t    \r\n\t    this.isRangeFormatElement = function(element) \r\n\t    {\r\n\t        return element && element.nodeType === 1 && (/^(BLOCKQUOTE|OL|UL|FIGCAPTION|TABLE|THEAD|TBODY|TR|TH|TD)$/i.test(element.nodeName));\r\n\t    };\r\n\t    \r\n\t    this.isMedia = function(node) \r\n\t    {\r\n\t        return node && /^(IMG|IFRAME|AUDIO|VIDEO|CANVAS)$/i.test(typeof node === 'string' ? node : node.nodeName);\r\n\t    };\r\n\t    \r\n\t    this.isBreak = function (node) \r\n\t    {\r\n\t        return node && /^BR$/i.test(typeof node === 'string' ? node : node.nodeName);\r\n\t    };\r\n\t    \r\n\t    this.isList = function (node) \r\n\t    {\r\n\t    \t return node && /^(OL|UL)$/i.test(typeof node === 'string' ? node : node.nodeName);\r\n\t    };\r\n\t    \r\n\t    this.isListCell = function (node) \r\n\t    {\r\n\t    \treturn node && /^LI$/i.test(typeof node === 'string' ? node : node.nodeName);\r\n\t    };\r\n\t    \r\n\t    this.isAnchor = function(node) \r\n\t    {\r\n\t    \treturn node && /^A$/i.test(typeof node === 'string' ? node : node.nodeName);\r\n\t    };\r\n\t    \r\n\t    this.trim = function(value) \r\n\t    {\r\n\t    \treturn value.replace(this.SPACE_REG_EXP_END, \"\").replace(this.SPACE_REG_EXP_START, \"\");\r\n\t    };\r\n\t\t\r\n\t\tthis.getOffset = function(element,recursive,doc) \r\n\t\t{\r\n\t\t\trecursive = Boolean.parse(recursive);\r\n\t\t\tdoc = doc ? doc : this.__nsEditor.__getDocument();\r\n\t\t\tvar body = doc.body;\r\n\t\t\tvar win = doc.defaultView || doc.parentWindow;\r\n\t\t\tvar docElem = doc.documentElement || {clientTop: 0,clientLeft: 0,scrollTop: 0,scrollLeft: 0};\r\n\t\t    var scrollTop = win.pageYOffset || docElem.scrollTop || body.scrollTop;\r\n\t\t    var scrollLeft = win.pageXOffset || docElem.scrollLeft || body.scrollLeft;\r\n\t\t    var clientTop = docElem.clientTop || body.clientTop || 0;\r\n\t\t    var clientLeft = docElem.clientLeft || body.clientLeft || 0;\r\n\t\t    var topValue = null;\r\n\t\t    var leftValue = null;\r\n\t\t    var rect = element.getBoundingClientRect();\r\n\t\t    if(!recursive && !this.__nsEditor.__isModeTextArea())\r\n\t\t    {\r\n\t\t    \t var offset = this.getOffset(this.__nsEditor.__compTextArea,true);\r\n\t\t         topValue = rect.top + offset.top;\r\n\t\t         leftValue = rect.left + offset.left;\r\n\t\t    }\r\n\t\t    else\r\n\t\t    {\r\n\t\t    \ttopValue = rect.top + scrollTop - clientTop;\r\n\t\t        leftValue = rect.left + scrollLeft - clientLeft;\r\n\t\t    }\r\n\t\t    return {\r\n\t\t        top: Math.round(topValue),\r\n\t\t        left: Math.round(leftValue),\r\n\t\t        width: rect.width,\r\n\t\t        height: rect.height\r\n\t\t    };\r\n\t\t};\r\n\t\t\r\n\t\tthis.getOffsetFromEditor = function(element,textArea,doc) \r\n\t\t{\r\n\t\t\ttextArea = textArea ? textArea : this.__nsEditor.__getTextArea();\r\n\t\t\tvar offsetLeft = 0;\r\n\t        var offsetTop = 0;\r\n\t        var offsetElement = element.nodeType === 3 ? element.parentElement : element;\r\n\r\n\t        while (offsetElement && !this.util.hasStyleClass(offsetElement,\"nsEditor\") && offsetElement !== textArea) \r\n\t        {\r\n\t            offsetLeft += offsetElement.offsetLeft;\r\n\t            offsetTop += offsetElement.offsetTop;\r\n\t            offsetElement = offsetElement.offsetParent;\r\n\t        }\r\n\t        var iframe = !this.__nsEditor.__isModeTextArea();\r\n\t        return {\r\n\t            left: offsetLeft + (iframe ? textArea.offsetLeft : 0),\r\n\t            top: (offsetTop - textArea.scrollTop) + (iframe ? textArea.parentElement.offsetTop : 0)\r\n\t        };\r\n\t\t};\r\n\t\t\r\n\t\tthis.getContentWidth = function(element,win) \r\n\t\t{\r\n\t\t    var getValue = function (value) \r\n\t\t    {\r\n\t\t    \tif(value)\r\n\t\t    \t{\r\n\t\t    \t\treturn parseInt(value, 10);\r\n\t\t    \t}\r\n\t\t    \treturn 0;\r\n\t\t    };\r\n\t\t    var style = win.getComputedStyle(element);\r\n\t\t    var width = element.offsetWidth;\r\n\t\t    var paddingLeft = getValue(style.getPropertyValue(\"padding-left\"));\r\n\t\t    var paddingRight = getValue(style.getPropertyValue(\"padding-right\"));\r\n\t\t    return (width - paddingLeft - paddingRight);\r\n\r\n\t\t};\r\n\t\t\r\n\t\tthis.isEditable = function(element) \r\n\t\t{\r\n\t\t\telement = element ? element : this.__nsEditor.__getTextArea();\r\n\t        if(element && element.nodeType === 1 && Boolean.parse(element.getAttribute(\"contenteditable\")))\r\n\t        {\r\n\t        \treturn true;\r\n\t        }\r\n\t        return false;\r\n\t    };\r\n\t    \r\n\t    this.isNonEditable = function (element) \r\n\t    {\r\n\t        return element && element.nodeType === 1 && !Boolean.parse(element.getAttribute(\"contenteditable\"));\r\n\t    };\r\n\t    \r\n\t    this.isEmptyTextNode = function(node) \r\n\t    {\r\n\t        if((this.util.isTextNode(node) && (!node.nodeValue || node.nodeValue.replace(this.INVISIBLE_SPACE_REG_EXP, \"\") .length === 0)))\r\n\t        {\r\n\t        \treturn true;\r\n\t        }\r\n\t        return false;\r\n\t    };\r\n\t    \r\n\t    this.isEmptyNode = function(node,regexNonEmptyTags) \r\n\t    {\r\n\t    \tif(!node) \r\n\t\t\t{\r\n\t            return true;\r\n\t        }\r\n\t\t\tif(this.util.isTextNode(node))\r\n\t\t\t{\r\n\t\t\t\treturn node.nodeValue === null || node.nodeValue.trim().length === 0;\r\n\t\t\t}\r\n\t\t\tregexNonEmptyTags = regexNonEmptyTags || /^(img|svg|canvas|input|textarea|form)$/;\r\n\t\t\tif(regexNonEmptyTags.test(node.nodeName.toLowerCase()))\r\n\t\t\t{\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\tvar self = this;\r\n\t\t\tvar value = this.util.loopAllChildren(node,function(paramNode) \r\n\t\t\t{\r\n                if ((self.util.isTextNode(paramNode) && paramNode.nodeValue !== null &&\r\n                    paramNode.nodeValue.trim().length !== 0) ||\r\n                    (self.util.isElement(paramNode) && regexNonEmptyTags.test(paramNode.nodeName.toLowerCase()))) \r\n                {\r\n                    return false;\r\n                }\r\n            });\r\n\t\t\treturn value;\r\n\t    };\r\n\t    \r\n\t    //to find whether element is a node related to the text style\r\n\t    this.isTextStyleElement = function (element) \r\n\t    {\r\n\t        return element && element.nodeType !== 3 && /^(strong|span|font|b|var|i|em|u|ins|s|strike|del|sub|sup|mark|a|label|code)$/i.test(element.nodeName);\r\n\t    };\r\n\t    \r\n\t    this.getCharLength = function(content,charCounterType) \r\n\t    {\r\n            return /byte/.test(charCounterType) ? this.getByteLength(content) : content.length;\r\n        }\r\n\t    \r\n\t    this.getByteLength = function(strExp) \r\n\t    {\r\n\t    \tvar win = this.__nsEditor.__getWindow();\r\n\t    \tvar browserDetail = this.__nsEditor.__browserDetail;\r\n\t        var encoder = win.encodeURIComponent;\r\n\t        var cr = 0;\r\n\t        var cl;\r\n\t        //edge\r\n\t        if (browserDetail.isIE && !browserDetail.isMSIE) \r\n\t        {\r\n\t            cl = win.unescape(encoder(strExp.toString())).length;\r\n\t            if (encoder(strExp.toString()).match(/(%0A|%0D)/gi) !== null) \r\n\t            {\r\n\t                cr = encoder(strExp.toString()).match(/(%0A|%0D)/gi).length;\r\n\t            }\r\n\t        } \r\n\t        else \r\n\t        {\r\n\t            cl = (new win.TextEncoder('utf-8').encode(strExp.toString())).length;\r\n\t        }\r\n\t        if (encoder(strExp.toString()).match(/(%0A|%0D)/gi) !== null) \r\n            {\r\n                cr = encoder(strExp.toString()).match(/(%0A|%0D)/gi).length;\r\n            }\r\n            return cl + cr;\r\n\t    }\r\n\t    \r\n\t    this.compareElements = function(element1, element2) \r\n\t    {\r\n\t    \tvar objRet = {};\r\n\t        var ele1 = element1;\r\n\t        var bNode = element2;\r\n\t        while (ele1 && ele2 && ele1.parentNode !== ele2.parentNode) \r\n\t        {\r\n\t            ele1 = ele1.parentNode;\r\n\t            ele2 = ele2.parentNode;\r\n\t        }\r\n\t        if (!ele1 || !ele2) \r\n\t        {\r\n\t        \tobjRet = {ancestor: null,element1: element1,element2: element2, result: 0};\r\n\t        }\r\n\t        else \r\n\t        {\r\n\t        \tvar children = ele1.parentNode.childNodes;\r\n\t\t        var aIndex = this.getIndexFromArray(children, ele1);\r\n\t\t        var bIndex = this.getIndexFromArray(children, ele2);\r\n\t\t        var result = aIndex > bIndex ? 1 : aIndex < bIndex ? -1 : 0;\r\n\t\t        objRet = {ancestor: ele1.parentNode,element1: element1,element2: element2,result: result};\r\n\t        }\r\n\t        return objRet;\r\n\t    };\r\n\t    \r\n\t    this.getIndexFromArray = function(arrData,value) \r\n\t    {\r\n\t    \tvar index = arrData.findIndex(function(paramValue,index,arr){\r\n\t    \t\tif(paramValue == value)\r\n\t    \t\t{\r\n\t    \t\t\treturn true;\r\n\t    \t\t}\r\n\t    \t});\r\n\t    \treturn index;\r\n\t    };\r\n\t    \r\n\t    this.setElementPosition = function(controller, referEl, position, offset)\r\n\t    {\r\n\t    \tvar rtl = false;\r\n\t    \toffset = offset ? offset :  {left: 0, top: 0};\r\n\t    \tvar body = this.__nsEditor.__getTextArea();\r\n\t    \tif (rtl)\r\n\t    \t{\r\n\t    \t\toffset.left *= -1;\r\n\t    \t}\r\n            var offset = this.getOffsetFromEditor(referEl,body);\r\n            controller.style.visibility = 'hidden';\r\n            controller.style.display = 'block';\r\n\r\n            // Height value of the arrow element is 11px\r\n            var topMargin = position === 'top' ? -(controller.offsetHeight + 2) : (referEl.offsetHeight + 12);\r\n            controller.style.top = (offset.top + topMargin + offset.top) + 'px';\r\n\r\n            var l = offset.left - body.scrollLeft + offset.left;\r\n            var controllerW = controller.offsetWidth;\r\n            var referElW = referEl.offsetWidth;\r\n\r\n            // rtl (Width value of the arrow element is 22px)\r\n            if (rtl) \r\n            {\r\n                var rtlW = (controllerW > referElW) ? controllerW - referElW : 0;\r\n                var rtlL = rtlW > 0 ? 0 : referElW - controllerW;\r\n                controller.style.left = (l - rtlW + rtlL) + 'px';\r\n                \r\n                if (rtlW > 0) \r\n                {\r\n                    controller.firstElementChild.style.left = ((controllerW - 14 < 10 + rtlW) ? (controllerW - 14) : (10 + rtlW)) + 'px';\r\n                }\r\n                \r\n                var overSize = body.offsetLeft - controller.offsetLeft;\r\n                if (overSize > 0) \r\n                {\r\n                    controller.style.left = '0px';\r\n                    controller.firstElementChild.style.left = overSize + 'px';\r\n                }\r\n            } \r\n            else \r\n            {\r\n                controller.style.left = l + 'px';\r\n\r\n                var overSize = body.offsetWidth - (controller.offsetLeft + controllerW);\r\n                if (overSize < 0) \r\n                {\r\n                    controller.style.left = (controller.offsetLeft + overSize) + 'px';\r\n                    //controller.firstElementChild.style.left = (20 - overSize) + 'px';\r\n                } \r\n                else \r\n                {\r\n                    //controller.firstElementChild.style.left = '20px';\r\n                }\r\n            }\r\n\r\n            controller.style.visibility = '';\r\n\t    };\r\n\t    \r\n\t    this.stopEvent = function(event)\r\n\t    {\r\n\t    \tevent = this.util.getEvent(event);\r\n\t    \tevent.preventDefault();\r\n\t    \tevent.stopPropagation();\r\n\t    \tevent.stopImmediatePropagation();\r\n\t    };\r\n\t    \r\n\t    //isWysiwygDiv\r\n\t    this.containsNode = function (node,type) \r\n\t    {\r\n\t    \tif(node)\r\n\t    \t{\r\n\t    \t\tvar textArea = this.__nsEditor.__getTextArea();\r\n\t    \t\tif(textArea.contains(node))\r\n\t    \t\t{\r\n\t    \t\t\tif(type)\r\n\t    \t\t\t{\r\n\t    \t\t\t\treturn this.util.isElementOfType(node,type);\r\n\t    \t\t\t}\r\n\t    \t\t\telse\r\n\t    \t\t\t{\r\n\t    \t\t\t\treturn true;\r\n\t    \t\t\t}\r\n\t    \t\t}\r\n\t    \t}\r\n\t        return false;\r\n\t    };\r\n\t    \r\n\t    this.onlyZeroWidthSpace = function(text) \r\n\t    {\r\n\t    \tvar onlyZeroWidthRegExp = new RegExp('^' + String.fromCharCode(8203) + '+$');\r\n\t        if (typeof text !== 'string')\r\n\t        {\r\n\t        \ttext = text.textContent;\r\n\t        }\r\n\t        return text === '' || onlyZeroWidthRegExp.test(text);\r\n\t    };\r\n\t    \r\n\t    this.getFormatElement = function(element,callback) \r\n\t    {\r\n\t        if (element)\r\n\t        {\r\n\t\t        while (element) \r\n\t\t        {\r\n\t\t            if (this.containsNode(element,\"div\"))\r\n\t\t            {\r\n\t\t            \treturn null;\r\n\t\t            }\r\n\t\t            if (this.isRangeFormatElement(element))\r\n\t\t            {\r\n\t\t            \telement.firstElementChild;\r\n\t\t            }\r\n\t\t            if (this.isFormatElement(element))\r\n\t\t            {\r\n\t\t            \tif(!callback || callback(element))\r\n\t\t            \t{\r\n\t\t            \t\treturn element;\r\n\t\t            \t}\r\n\t\t            }\r\n\t\t            element = element.parentNode;\r\n\t\t        }\r\n\t        }\r\n\t        return null;\r\n\t    };\r\n\t    \r\n\t    //safeRemove\r\n\t    this.removeNode = function(node) \r\n\t    {\r\n\t    \tif (node && node.parentNode)\r\n\t    \t{\r\n\t    \t\tnode.parentNode.removeChild(node);\r\n\t    \t}\r\n\t    };\r\n\t    \r\n\t    this.isIgnoreNodeChange = function (element) \r\n\t    {\r\n\t        return element && element.nodeType !== 3 && (this.isNonEditable(element) || !this.isTextStyleElement(element));\r\n\t    };\r\n\t    \r\n\t    //wrap\r\n\t    this.wrapNode = function(currentNode,newParent)\r\n\t    {\r\n\t\t\tif(currentNode.parentNode) \r\n\t\t\t{\r\n\t\t\t\tvar doc = this.__nsEditor.__getDocument();\r\n\t\t\t\tvar wrapper = this.util.isString(newParent) ? this.util.createElement(tag,null,null,doc) : newParent;\r\n\t\t\t\tthis.selection.saveSelection();\r\n\t\t\t\tcurrentNode.parentNode.insertBefore(wrapper,currentNode);\r\n\t\t\t\twrapper.appendChild(currentNode);\r\n\t\t\t\tthis.selection.restoreSelection();\r\n\t\t\t\treturn wrapper;\r\n\t\t\t}\r\n\t    };\r\n\t    \r\n\t    //wrapInline\r\n\t    this.wrapAllInlineSiblings = function (node,tag) \r\n\t    {\r\n\t    \tthis.selection.saveSelection();\r\n\t    \tvar doc = this.__nsEditor.__getDocument();\r\n\t    \tvar win = this.__nsEditor.__getWindow();\r\n\t    \tvar textArea = this.__nsEditor.__getTextArea();\r\n\t        var startNode = node;\r\n\t        var endNode = node;\r\n\t        var findNext = false;\r\n\t        do \r\n\t        {\r\n\t            findNext = false;\r\n\t            var tmpNode = startNode.previousSibling;\r\n\t            if (tmp && !this.isBlock(tmp,win)) \r\n\t            {\r\n\t                findNext = true;\r\n\t                startNode = tmpNode;\r\n\t            }\r\n\t        } \r\n\t        while(findNext);\r\n\t        do \r\n\t        {\r\n\t            findNext = false;\r\n\t            var tmpNode = endNode.nextSibling;\r\n\t            if (tmpNode && !this.isBlock(tmp,win)) \r\n\t            {\r\n\t                findNext = true;\r\n\t                endNode = tmpNode;\r\n\t            }\r\n\t        } \r\n\t        while(findNext);\r\n\t        var parent = this.util.isString(tag) ? doc.createElement(tag) : tag;\r\n\t        if (startNode.parentNode) \r\n\t        {\r\n\t            startNode.parentNode.insertBefore(parent,startNode);\r\n\t        }\r\n\t        var nextNode = startNode;\r\n\t        while(nextNode) \r\n\t        {\r\n\t        \tnextNode = startNode.nextSibling;\r\n\t            parent.appendChild(startNode);\r\n\t            if (startNode === endNode || !nextNode) \r\n\t            {\r\n\t                break;\r\n\t            }\r\n\t            startNode = nextNode;\r\n\t        }\r\n\t        this.selection.restoreSelection();\r\n\t        return parent;\r\n\t    };\r\n\t    \r\n\t    //normalizeNode\r\n\t    this.mergeTextNodes = function(node)\r\n\t    {\r\n\t    \tif(node)\r\n\t    \t{\r\n\t    \t\tif (this.util.isTextNode(node) && node.nodeValue != null && node.parentNode) \r\n\t    \t\t{\r\n\t    \t\t\twhile (this.util.isTextNode(node.nextSibling)) \r\n\t    \t\t\t{\r\n\t    \t\t\t\tif (node.nextSibling.nodeValue != null) \r\n\t    \t\t\t\t{\r\n\t    \t\t\t\t\tnode.nodeValue += node.nextSibling.nodeValue;\r\n\t    \t\t\t\t}\r\n\t    \t\t\t\tnode.nodeValue = node.nodeValue.replace(this.INVISIBLE_SPACE_REG_EXP,\"\");\r\n\t    \t\t\t\tthis.removeNode(node.nextSibling);\r\n\t    \t\t\t}\r\n\t    \t\t} else \r\n\t    \t\t{\r\n\t    \t\t\tthis.mergeTextNodes(node.firstChild);\r\n\t    \t\t}\r\n\t    \t\tthis.mergeTextNodes(node.nextSibling);\r\n\t    \t}\r\n\t    };\r\n\t    \r\n\t    this.insertNodeWrappingRange = function(node)\r\n\t    {\r\n\t    \tif(node)\r\n\t    \t{\r\n\t    \t\tif(!this.selection)\r\n\t    \t\t{\r\n\t    \t\t\tthis.selection = this.__nsEditor.__selection;\r\n\t    \t\t}\r\n\t    \t\tif(this.selection.isCollapsed())\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.selection.insertNode(node,false,false);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tvar range = this.selection.getRange();\r\n\t\t\t\t\tvar fragment = range.extractContents();\r\n\t\t\t\t\tnode.appendChild(fragment);\r\n\t\t\t\t\trange.insertNode(node);\r\n\t\t\t\t}\r\n\t    \t}\r\n\t    }\r\n\t    \r\n    };\r\n\t\r\n\treturn NSEditorUtil;\r\n})();\r\nnsModuleExport(this,\"NSEditorUtil\",NSEditorUtil); var NSToolBar = (function()\r\n{\r\n\tvar NSToolBar = function(nsEditor)\r\n\t{\r\n\t\tthis.__nsEditor = nsEditor;\r\n\t\tthis.util = nsEditor.util;\r\n\t\tthis.editorUtil = nsEditor.editorUtil;\r\n\t\tthis.selection = nsEditor.__selection;\r\n\t\t\r\n\t\tthis.__parentContainer = null;\r\n\t\tthis.__divToolBarContainer = null;\r\n\t\tthis.__divToolBarContent = null;\r\n\t\tthis.__editorDropDown = null;\r\n\t\t\r\n\t\tthis.__groupedContainer = null;\r\n\t\tthis.__btnGrouped = null;\r\n\t\tthis.__groupedContainerDropdown = null;\r\n\t\tthis.__groupedContainerDropdownContent = null;\r\n\t\t\r\n\t\tthis.__nsToolTipInElement = null;\r\n\t\tthis.__config = null;\r\n\t\tthis.__toolBarPadding = null;\r\n\t\tthis.__groupedTools = [];\r\n\t\t\r\n\t\tthis.__windowClickRef = null;\r\n\t\t\r\n\t\tthis.__arrowSVG = \"<svg class=\\\"nsEditorIcon nsEditorIconArrow\\\" viewBox=\\\"0 0 10 10\\\"><path d=\\\"M.941 4.523a.75.75 0 1 1 1.06-1.06l3.006 3.005 3.005-3.005a.75.75 0 1 1 1.06 1.06l-3.549 3.55a.75.75 0 0 1-1.168-.136L.941 4.523z\\\"></path></svg>\"\r\n\t\t\r\n\t\tthis.__initialize = function()\r\n\t\t{\r\n\t\t\tvar self = this;\r\n\t\t\tthis.__nsEditor.__listenInternalEvent(\"resize\",this.__resizeHandler.bind(this));\r\n\t\t\tthis.__nsEditor.__listenInternalEvent(\"lineNumberVisibilityChanged\",function(event){\r\n\t\t\t\tself.__divToolBarContainer.style.paddingLeft = (self.__nsEditor.__divLineNumberContainer.offsetWidth + 10) + \"px\";\r\n\t\t\t});\r\n\t\t\tthis.__nsEditor.__listenInternalEvent(\"iframeInitialized\",function(event){\r\n\t\t\t\tif(self.__nsEditor.__frameContentWindow)\r\n\t\t\t\t{\r\n\t\t\t\t\tself.util.addEvent(self.__nsEditor.__frameContentWindow,\"click\",self.__windowClickRef);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t\tthis.__nsEditor.__listenInternalEvent(\"viewSourceChanged\",function(event){\r\n\t\t\t\tvar isDefaultDisabled = event.detail.isSourceMode;\r\n\t\t\t\tvar item = event.detail.item;\r\n\t\t\t\tvar key = event.detail.key;\r\n\t\t\t\tvar arrKeys = Object.keys(self.__nsEditor.__toolBarButton);\r\n\t\t\t\tfor(var count = 0;count < arrKeys.length;count++)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar itemKey = arrKeys[count];\r\n\t\t\t\t\tvar toolBarItem = self.__nsEditor.__toolBarButton[itemKey];\r\n\t\t\t\t\tif(item != toolBarItem)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar disabled = toolBarItem.checkDisability ? toolBarItem.checkDisability(itemKey,toolBarItem,item,key,isDefaultDisabled) : true;\r\n\t\t\t\t\t\tself.__makeToolBarItemDisabled(toolBarItem,(isDefaultDisabled ? disabled : !disabled));\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t\tthis.__nsEditor.__listenInternalEvent(\"textAreaInitialized\",function(event){\r\n\t\t\t\tsetTimeout(function()\r\n\t\t\t\t{\r\n\t\t\t\t\tself.__updateToolBarGrouping.call(self)\r\n\t\t\t\t}, 500)\r\n\t\t\t});\r\n\t\t};\r\n\t\t\r\n\t\tthis.getToolBarContainer = function()\r\n\t\t{\r\n\t\t\treturn this.__divToolBarContainer;\r\n\t\t};\r\n\t\t\r\n\t\tthis.createToolBar = function()\r\n\t\t{\r\n\t\t\tthis.__parentContainer = this.__nsEditor.__divOuterContainer;\r\n\t\t\tthis.__config = this.__nsEditor.__config;\r\n\t\t\tthis.__nsToolTipInElement = new this.util.nsToolTipInElement();\r\n\t\t\tthis.__divToolBarContainer = this.util.createDiv(this.__nsEditor.getID() + \"toolbarcontainer\",\"nsEditorToolBarContainer\");\r\n\t\t\tthis.__parentContainer.appendChild(this.__divToolBarContainer);\r\n\t\t\tthis.__divToolBarContent = this.util.createDiv(this.__nsEditor.getID() + \"toolbarcontent\",\"nsEditorToolBarContent\");\r\n\t\t\tthis.__divToolBarContainer.appendChild(this.__divToolBarContent);\r\n\t\t\tif(this.__config[\"enableToolBar\"])\r\n\t\t\t{\r\n\t\t\t\tthis.__createToolBarComponents();\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthis.__nsEditor.__handleVisibilityOfComponent(this.__divToolBarContainer,\"enableToolBar\");\r\n\t\t\t}\r\n\t\t\tthis.__initSticy();\r\n\t\t\tif(!this.__windowClickRef)\r\n\t\t\t{\r\n\t\t\t\tthis.__windowClickRef = this.__windowClickHandler.bind(this);\r\n\t\t\t\tthis.util.addEvent(this.__nsEditor.__context,\"click\",this.__windowClickRef);\r\n\t\t\t}\r\n\t\t\tthis.__editorDropDown =  this.util.createElement(\"ul\",this.__nsEditor.getID() + \"dropDown\",\"nsEditorToolBarDropdown\");\r\n\t\t\tthis.__nsEditor.__compFixed.appendChild(this.__editorDropDown);\r\n\t\t};\r\n\t\t\r\n\t\tthis.updateToolbar = function(element)\r\n\t\t{\r\n\t\t\tvar self = this;\r\n\t\t\tvar checkForTags = function(arrTags,item)\r\n\t\t\t{\r\n\t\t\t\tif(arrTags && arrTags.length > 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar tempElement = element;\r\n\t\t\t\t\twhile (tempElement && tempElement.nodeType == 1) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (arrTags.indexOf(tempElement.tagName.toLowerCase()) > -1) \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tself.__makeToolBarItemActive(item,true);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\ttempElement = tempElement.parentNode;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t};\r\n\t\t\tvar checkForCSS = function(objCSS,item)\r\n\t\t\t{\r\n\t\t\t\tif(objCSS)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar tempElement = element;\r\n\t\t\t\t\twhile (tempElement && tempElement.nodeType == 1) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar arrCSS = Object.keys(objCSS);\r\n\t\t\t\t\t\tfor(var cssCount = 0;cssCount < arrCSS.length;cssCount++)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif(isCSSValuePresentInElement(arrCSS[cssCount],objCSS[arrCSS[cssCount]]))\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tself.__makeToolBarItemActive(item,true);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\ttempElement = tempElement.parentNode;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tself.__nsEditor.__selection.setFocus();\r\n\t\t\t\t}\r\n\t\t\t};\r\n\t\t\tvar isCSSValuePresentInElement = function(property,value)\r\n\t\t\t{\r\n\t\t\t\tvar cssValue = self.util.getStyleValue(element,property);\r\n\t\t\t\tif(cssValue)\r\n\t\t\t\t{\r\n\t\t\t\t\tif(typeof (value) === \"function\")\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar callback = value;\r\n\t\t\t\t\t\tif(callback && callback(cssValue.toString().toLowerCase()))\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse if(cssValue.toString().toLowerCase() === value)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\treturn false;\r\n\t\t\t};\r\n\t\t\t\r\n\t\t\tvar arrKeys = Object.keys(this.__nsEditor.__toolBarButton);\r\n\t\t\tfor(var count = 0;count < arrKeys.length;count++)\r\n\t\t\t{\r\n\t\t\t\tvar key = arrKeys[count];\r\n\t\t\t\tvar item = this.__nsEditor.__toolBarButton[key];\r\n\t\t\t\tthis.__makeToolBarItemActive(item,false);\r\n\t\t\t\tvar arrTags = item.tags;\r\n\t\t\t\tcheckForTags(arrTags,item);\r\n\t\t\t\tvar css = item.css;\r\n\t\t\t\tcheckForCSS(css,item);\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.__stickyScrollRef)\r\n\t    \t{\r\n\t    \t\tthis.util.removeEvent(this.__nsEditor.__context,\"scroll wheel mousewheel\",this.__stickyScrollRef);\r\n\t    \t\tthis.__stickyScrollRef = null;\r\n\t    \t}\r\n\t\t\tif(this.__windowClickRef)\r\n\t\t\t{\r\n\t\t\t\tthis.util.removeEvent(this.__nsEditor.__context,\"click\",this.__windowClickRef);\r\n\t\t\t\tif(this.__nsEditor.__frameContentWindow)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.util.removeEvent(this.__nsEditor.__frameContentWindow,\"click\",this.__windowClickRef);\r\n\t\t\t\t}\r\n\t\t\t\tthis.__windowClickRef = null;\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__createToolBarComponents = function()\r\n\t\t{\r\n\t\t\tthis.util.removeAllChildren(this.__divToolBarContent);\r\n\t\t\tif(this.__config[\"toolBarButton\"] && this.__config[\"toolBarButton\"].length > 0)\r\n\t\t\t{\r\n\t\t\t\tfor(var count = 0;count < this.__config[\"toolBarButton\"].length;count++)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar key = this.__config[\"toolBarButton\"][count];\r\n\t\t\t\t\tif(this.__nsEditor.__toolBarButton[key])\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.__createToolBarButton(this.__nsEditor.__toolBarButton[key],this.__divToolBarContent,key);\r\n\t\t\t\t\t\tthis.__updateShortKeyDictionary(this.__nsEditor.__toolBarButton[key],this.__divToolBarContent,key);\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.__createToolBarButton = function(item,parent,key)\r\n\t\t{\r\n\t\t\tif(item)\r\n\t\t\t{\r\n\t\t\t\tvar self = this;\r\n\t\t\t\tvar btnItem =  this.util.createElement(\"button\",null,\"nsEditorToolBarButton\");\r\n\t\t\t\tbtnItem.innerHTML = item.html;\r\n\t\t\t\tif(item.tooltip && item.tooltip.length > 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__nsToolTipInElement.addToolTip(btnItem,item.tooltip);\r\n\t\t\t\t}\r\n\t\t\t\tif(item.isDropdown)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.util.addStyleClass(btnItem,\"nsEditorToolBarButtonDropdown\");\r\n\t\t\t\t\tbtnItem.appendChild(this.util.getElementFromHtml(this.__arrowSVG));\r\n\t\t\t\t\tthis.util.addEvent(btnItem,\"click\",(function(item){\r\n\t\t\t\t\t\treturn function(event){\r\n\t\t\t\t\t\t\tself.__toolBarDropdownClickHandler.call(self,item,key,event);\r\n\t\t\t\t\t\t};\r\n\t\t\t\t\t})(item));\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(btnItem,\"click\",(function(item){\r\n\t\t\t\t\t\treturn function(event){\r\n\t\t\t\t\t\t\tself.__toolBarButtonClickHandler.call(self,item,key,event);\r\n\t\t\t\t\t\t};\r\n\t\t\t\t\t})(item));\r\n\t\t\t\t}\r\n\t\t\t\tif(parent)\r\n\t\t\t\t{\r\n\t\t\t\t\tparent.appendChild(btnItem);\r\n\t\t\t\t}\r\n\t\t\t\titem.control = btnItem;\r\n\t\t\t\titem.selected = false;\r\n\t\t\t\treturn btnItem;\r\n\t\t\t}\r\n\t\t\treturn null;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__updateShortKeyDictionary = function(item,parent,key)\r\n\t\t{\r\n\t\t\tif(item)\r\n\t\t\t{\r\n\t\t\t\tif(item.shortKey)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar shortKey = item.shortKey;\r\n\t\t\t\t\tif(!this.util.isArray(shortKey))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tshortKey = [shortKey];\r\n\t\t\t\t\t}\r\n\t\t\t\t\tfor(var count = 0;count < shortKey.length;count++)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar tempKey = shortKey[count].toLowerCase();\r\n\t\t\t\t\t\tif(this.__nsEditor.__objShortKey[tempKey])\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tthis.util.warning(\"NSEditor\",tempKey + \" has already been assigned to \" + this.__nsEditor.__objShortKey[tempKey].key + \". It will overriden by \" + key + \".\")\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tthis.__nsEditor.__objShortKey[tempKey] = {item: item,parent: parent,key: key};\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tvar arrItem = item.dataSource;\r\n\t\t\t\tif(arrItem && arrItem.length > 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tfor(var count = 0;count < arrItem.length;count++)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar childItem = arrItem[count];\r\n\t\t\t\t\t\tif(childItem.hasOwnProperty(\"htmlKey\"))\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tchildItem = this.__nsEditor.__toolBarButton[childItem[\"htmlKey\"]];\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tif(childItem)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tthis.__updateShortKeyDictionary(childItem,item,childItem.value);\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.__makeToolBarItemActive = function(item,isActive)\r\n\t\t{\r\n\t\t\tif(item && this.__nsEditor.__config.enableToolBarActive)\r\n\t\t\t{\r\n\t\t\t\titem.selected = isActive;\r\n\t\t\t\tif(item.control)\r\n\t\t\t\t{\r\n\t\t\t\t\tisActive ? this.util.addStyleClass(item.control,\"nsEditorToolBarItemActive\") : this.util.removeStyleClass(item.control,\"nsEditorToolBarItemActive\");\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__makeToolBarItemDisabled = function(item,isDisabled)\r\n\t\t{\r\n\t\t\tif(item)\r\n\t\t\t{\r\n\t\t\t\titem.selected = false;\r\n\t\t\t\titem.disabled = isDisabled;\r\n\t\t\t\tif(item.control)\r\n\t\t\t\t{\r\n\t\t\t\t\tisDisabled ? this.util.addStyleClass(item.control,\"nsEditorToolBarButtonDisabled\") : this.util.removeStyleClass(item.control,\"nsEditorToolBarButtonDisabled\");\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__createToolBarDropdown = function(parentItem,key,event)\r\n\t\t{\r\n\t\t\tvar arrItem = parentItem.dataSource;\r\n\t\t\tif(arrItem && arrItem.length > 0)\r\n\t\t\t{\r\n\t\t\t\tvar self = this;\r\n\t\t\t\tthis.util.removeAllChildren(this.__editorDropDown);\r\n\t\t\t\tfor(var count = 0;count < arrItem.length;count++)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar item = arrItem[count];\r\n\t\t\t\t\tvar value = item.value;\r\n\t\t\t\t\tif(item.hasOwnProperty(\"htmlKey\"))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\titem = this.__nsEditor.__toolBarButton[item[\"htmlKey\"]];\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif(item)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar child = this.util.createElement(\"li\",null,\"nsEditorToolBarDropdownItem\");\r\n\t\t\t\t\t\tchild.innerHTML = item.html;\r\n\t\t\t\t\t\tchild.setAttribute(\"data-nsEditor-value\",value);\r\n\t\t\t\t\t\tthis.util.addEvent(child,\"click\",(function(item){\r\n\t\t\t\t\t\t\treturn function(event){\r\n\t\t\t\t\t\t\t\tself.__toolBarButtonClickHandler.call(self,item,key,event);\r\n\t\t\t\t\t\t\t};\r\n\t\t\t\t\t\t})(item));\r\n\t\t\t\t\t\tthis.__editorDropDown.appendChild(child);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tthis.__placeElementByEvent(this.__editorDropDown,event,{left: -22,top: 15});\r\n\t\t\t\treturn this.__editorDropDown;\r\n\t\t\t}\r\n\t\t\treturn null;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__toolBarDropdownClickHandler = function(item,key,event)\r\n\t\t{\r\n\t\t\tvar dropdown = this.__createToolBarDropdown(item,event);\r\n\t\t\tif(dropdown)\r\n\t\t\t{\r\n\t\t\t\tthis.__showToolBarDropdown(dropdown);\r\n\t\t\t\tthis.editorUtil.stopEvent(event);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__toolBarButtonClickHandler = function(item,key,event)\r\n\t\t{\r\n\t\t\tif(item)\r\n\t\t\t{\r\n\t\t\t\tif(!this.__nsEditor.getDisabled())\r\n\t\t\t\t{\r\n\t\t\t\t\tif(item.command)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.__nsEditor.__executeCommand(item.command,item,key);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif(item.click)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\titem.click(item,key,event);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tthis.__makeToolBarItemActive(item,true);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__windowClickHandler = function(event)\r\n\t\t{\r\n\t\t\t//if(this.hasFocus())\r\n\t\t\t//{\r\n\t\t\t\tif (!this.util.hasStyleClass(event.target,\"nsEditorToolBarButtonDropdown\")) \r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__hideToolBarDropdown();\r\n\t\t\t\t}\r\n\t\t\t\tthis.__hideGroupedPopUp();\r\n\t\t\t//}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__showToolBarDropdown = function(dropdown)\r\n\t\t{\r\n\t\t\tif(!this.__isToolBarDropdownVisible())\r\n\t\t\t{\r\n\t\t\t\tdropdown = dropdown || this.__editorDropDown;\r\n\t\t\t\tvar con = this.__isGroupedPopUpVisible() ? null : this.__parentContainer;\r\n\t\t\t\tvar maxZIndex = this.util.getMaxZIndex(con);\r\n\t\t\t\tif(maxZIndex > 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar parent = dropdown.parentNode;\r\n\t\t\t\t\tparent.style.zIndex = maxZIndex + 1;\r\n\t\t\t\t\tdropdown.style.zIndex = maxZIndex + 1;\r\n\t\t\t\t}\r\n\t\t\t\tthis.util.addStyleClass(dropdown,\"nsEditorToolBarDropdownShow\");\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__hideToolBarDropdown = function(dropdown)\r\n\t\t{\r\n\t\t\tdropdown = dropdown || this.__editorDropDown;\r\n\t\t\tthis.util.removeStyleClass(dropdown,\"nsEditorToolBarDropdownShow\");\r\n\t\t\tvar parent = dropdown.parentNode;\r\n\t\t\tparent.style.zIndex = \"\";\r\n\t\t\tdropdown.style.zIndex = \"\";\r\n\t\t};\r\n\t\t\r\n\t\tthis.__isToolBarDropdownVisible = function(dropdown)\r\n\t\t{\r\n\t\t\tdropdown = dropdown || this.__editorDropDown;\r\n\t\t\treturn this.util.hasStyleClass(dropdown,\"nsEditorToolBarDropdownShow\");\r\n\t\t};\r\n\t\t\r\n\t\tthis.__resizeHandler = function(event)\r\n\t\t{\r\n\t\t\tvar origEvent = event.originalEvent;\r\n\t\t\tthis.__hideToolBarDropdown();\r\n\t\t\tthis.__hideToolBarDropdown();\r\n\t\t\tthis.__updateToolBarGrouping();\r\n\t\t\tthis.__stickyScrollHandler(event);\r\n\t\t};\r\n\t\t\r\n\t\tthis.__updateToolBarGrouping = function()\r\n\t\t{\r\n\t\t\tif (this.__divToolBarContainer && this.__divToolBarContainer.parentNode) \r\n\t\t\t{\r\n\t\t\t\tvar beforeGroupedTools = this.__groupedTools.length;\r\n\t\t\t\tvar hasToolGrouped = false;\r\n\r\n\t\t\t\twhile(this.__isToolbarOverflowing()) \r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__groupLastTool();\r\n\t\t\t\t\thasToolGrouped = true;\r\n\t\t\t\t}\r\n\t\t\t\tif (!hasToolGrouped && this.__groupedTools.length) \r\n\t\t\t\t{\r\n\t\t\t\t\twhile(this.__groupedTools.length && !this.__isToolbarOverflowing()) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.__ungroupFirstTool();\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (this.__isToolbarOverflowing()) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.__groupLastTool();\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tif (this.__groupedTools.length !== beforeGroupedTools) \r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__nsEditor.__dispatchInternalEvent(\"toolbarUpdate\");\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tthis.__createHorizontalSeparator\r\n\t\t};\r\n\t\t\r\n\t\tthis.__isToolbarOverflowing = function()\r\n\t\t{\r\n\t\t\tvar win = this.__nsEditor.__getWindow();\r\n\t\t\tvar arrToolBar = this.__nsEditor.__config.toolBarButton;\r\n\t\t\tvar retValue = false;\r\n\t\t\tif(win && arrToolBar && arrToolBar.length) \r\n\t\t\t{\r\n\t\t\t\t//uiDirection for later use\r\n\t\t\t\tvar uiDir = \"ltr\";\r\n\t\t\t\tvar toolbarRect = this.__divToolBarContainer.getBoundingClientRect();\r\n\t\t\t\tvar lastChildRect = this.__divToolBarContainer.lastChild.getBoundingClientRect();\r\n\t\t\t\tif (!this.__toolBarPadding) \r\n\t\t\t\t{\r\n\t\t\t\t\tvar cssProperty = (uiDir == \"ltr\") ? \"paddingRight\" : \"paddingLeft\";\r\n\t\t\t\t\t//this.__toolBarPadding = this.util.getStyleValue(this.__divToolBarContainer,cssProperty,false,true,win);\r\n\t\t\t\t\tvar computedStyle = win.getComputedStyle(this.__divToolBarContainer);\r\n\t\t\t\t\tthis.__toolBarPadding = parseInt(computedStyle[cssProperty]);\r\n\t\t\t\t}\r\n\t\t\t\tif (uiDir == \"ltr\") \r\n\t\t\t\t{\r\n\t\t\t\t\t//console.log(lastChildRect.right + \" > \" + (toolbarRect.right - this.__toolBarPadding));\r\n\t\t\t\t\tretValue = (lastChildRect.right) > (toolbarRect.right - this.__toolBarPadding);\r\n\t\t\t\t} \r\n\t\t\t\telse \r\n\t\t\t\t{\r\n\t\t\t\t\tretValue = lastChildRect.left < toolbarRect.left + this.__toolBarPadding;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\treturn retValue;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__groupLastTool = function()\r\n\t\t{\r\n\t\t\tif (!this.__groupedTools.length) \r\n\t\t\t{\r\n\t\t\t\tthis.__divToolBarContainer.appendChild(this.__getOverflowContainer());\r\n\t\t\t}\r\n\t\t\tvar arrItem = this.__divToolBarContent.querySelectorAll(\".nsEditorToolBarButton\");\r\n\t\t\tif(arrItem && arrItem.length)\r\n\t\t\t{\r\n\t\t\t\tvar btnItem = arrItem[arrItem.length - 1];\r\n\t\t\t\tthis.__addToolInParent(btnItem,this.__groupedContainerDropdownContent,true);\r\n\t\t\t\tthis.__groupedTools.unshift(btnItem);\r\n\t\t\t\tthis.__refreshDividerInGroupedContent();\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__ungroupFirstTool = function()\r\n\t\t{\r\n\t\t\tvar btnItem = this.__groupedTools[0];//this.__groupedContainerDropdownContent.querySelectorAll(\".nsEditorToolBarButton\")[0];\r\n\t\t\tthis.__addToolInParent(btnItem,this.__divToolBarContent,false);\r\n\t\t\tthis.__groupedTools.splice(0,1);\r\n\t\t\tif (!this.__groupedTools.length) \r\n\t\t\t{\r\n\t\t\t\tthis.__divToolBarContainer.removeChild(this.__getOverflowContainer());\r\n\t\t\t}\r\n\t\t\t//this.__refreshDividerInGroupedContent();\r\n\t\t};\r\n\t\t\r\n\t\tthis.__getOverflowContainer = function()\r\n\t\t{\r\n\t\t\tif(!this.__groupedContainer)\r\n\t\t\t{\r\n\t\t\t\tthis.__groupedContainer = this.util.createDiv(null,\"nsEditorToolBarOveflowCon\");\r\n\t\t\t\tthis.__btnGrouped =  this.util.createElement(\"button\",null,\"nsEditorToolBarButton\");\r\n\t\t\t\tthis.__btnGrouped.innerHTML = \"<i class='ns-icon ns-editor-vertical-dots' aria-hidden='true'></i>\"; \r\n\t\t\t\tthis.__nsToolTipInElement.addToolTip(this.__btnGrouped,\"Show Tools\");\r\n\t\t\t\tthis.__groupedContainer.appendChild(this.__btnGrouped);\r\n\t\t\t\tthis.util.addEvent(this.__btnGrouped,\"click\",this.__handleOverflowClick.bind(this));\r\n\t\t\t\tvar content = \"<div class=\\\"nsEditorToolBarOveflowDropdown\\\">\\r\\n\" + \r\n\t\t\t\t\t\t\"\t<div class=\\\"nsEditorToolBarOveflowDropdownToolbar\\\">\\r\\n\" + \r\n\t\t\t\t\t\t\"\t\t<div class=\\\"nsEditorToolBarOveflowDropdownContent\\\">\\r\\n\" + \r\n\t\t\t\t\t\t\"\t\t</div>\\r\\n\" + \r\n\t\t\t\t\t\t\"\t</div>\\r\\n\" + \r\n\t\t\t\t\t\t\"</div>\";\r\n\t\t\t\tthis.__groupedContainerDropdown = this.util.getElementFromHtml(content);\r\n\t\t\t\tthis.__nsEditor.__compFixed.appendChild(this.__groupedContainerDropdown);\r\n\t\t\t\tthis.__groupedContainerDropdownContent = this.__groupedContainerDropdown.querySelector(\".nsEditorToolBarOveflowDropdownContent\");\r\n\t\t\t}\r\n\t\t\treturn this.__groupedContainer;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__refreshDividerInGroupedContent = function()\r\n\t\t{\r\n\t\t\tvar arrItem = this.__groupedContainerDropdownContent.querySelectorAll(\".nsEditorToolBarHorizontalSeparator\");\r\n\t\t\tfor(var count = arrItem.length - 1;count > -1;count--)\r\n\t\t\t{\r\n\t\t\t\tthis.__groupedContainerDropdownContent.removeChild(arrItem[count]);\r\n\t\t\t}\r\n\t\t\tarrItem = this.__groupedContainerDropdownContent.querySelectorAll(\".nsEditorToolBarButton\");\r\n\t\t\tvar afterElement = 3;\r\n\t\t\tfor(var count = afterElement - 1;count < arrItem.length;count = count + afterElement)\r\n\t\t\t{\r\n\t\t\t\tvar btn = arrItem[count];\r\n\t\t\t\tvar div = this.util.createDiv(null,\"nsEditorToolBarHorizontalSeparator\");\r\n\t\t\t\tthis.util.insertAfterElement(btn,div);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__addToolInParent = function(btnItem,parent,isFirst)\r\n\t\t{\r\n\t\t\tisFirst ? parent.insertBefore(btnItem,parent.firstChild) : parent.appendChild(btnItem);\r\n\t\t};\r\n\t\t\r\n\t\tthis.__handleOverflowClick = function(event)\r\n\t\t{\r\n\t\t\tthis.__isGroupedPopUpVisible() ? this.__hideGroupedPopUp() : this.__showGroupedPopUp();\r\n\t\t\tthis.editorUtil.stopEvent(event);\r\n\t\t};\r\n\t\t\r\n\t\tthis.__showGroupedPopUp = function()\r\n\t\t{\r\n\t\t\tif(!this.__isGroupedPopUpVisible())\r\n\t\t\t{\r\n\t\t\t\tvar con = this.__groupedContainerDropdown;\r\n\t\t\t\tthis.util.addStyleClass(con,\"nsEditorToolBarOveflowDropdownVisible\");\r\n\t\t\t\tvar rect = this.__groupedContainerDropdownContent.getBoundingClientRect();\r\n\t\t\t\tcon.style.width = rect.width + \"px\";\r\n\t\t\t\t//console.log(con.getBoundingClientRect().width + \" == \" + this.__groupedContainerDropdownContent.getBoundingClientRect().width);\r\n\t\t\t\tthis.__placeElementByEvent(con,event,{left: (-1 * rect.width) ,top: ((this.__btnGrouped.getBoundingClientRect().height) / 2)});\r\n\t\t\t\tvar maxZIndex = this.util.getMaxZIndex(this.__parentContainer);\r\n\t\t\t\tif(maxZIndex > 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar parent = con.parentNode;\r\n\t\t\t\t\tparent.style.zIndex = maxZIndex + 1;\r\n\t\t\t\t\tcon.style.zIndex = maxZIndex + 2;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__hideGroupedPopUp = function()\r\n\t\t{\r\n\t\t\tif(this.__groupedContainerDropdown)\r\n\t\t\t{\r\n\t\t\t\tvar con = this.__groupedContainerDropdown;\r\n\t\t\t\tthis.util.removeStyleClass(con,\"nsEditorToolBarOveflowDropdownVisible\");\r\n\t\t\t\tcon.style.width = \"\";\r\n\t\t\t\tvar parent = con.parentNode;\r\n\t\t\t\tparent.style.zIndex = \"\";\r\n\t\t\t\tcon.style.zIndex = \"\";\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__isGroupedPopUpVisible = function()\r\n\t\t{\r\n\t\t\treturn this.util.hasStyleClass(this.__groupedContainerDropdown,\"nsEditorToolBarOveflowDropdownVisible\");\r\n\t\t};\r\n\t\t\r\n\t\t//part for sticky header\r\n\t    \r\n\t    this.__stickyScrollRef = null;\r\n\t    this.__compDuplicate = null;\r\n\t    this.__isSticked = false;\r\n\t    this.__initSticy = function () \r\n\t\t{\r\n\t    \tif(!this.__stickyScrollRef)\r\n\t    \t{\r\n\t    \t\tthis.__stickyScrollRef = this.__stickyScrollHandler.bind(this);\r\n\t    \t\tthis.util.addEvent(this.__nsEditor.__context,\"scroll wheel mousewheel\",this.__stickyScrollRef);\r\n\t    \t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__stickyScrollHandler = function (event) \r\n\t\t{\r\n\t\t\t//event = this.util.getEvent(event);\r\n\t\t\tvar win = this.__nsEditor.__context;\r\n\t\t\tvar doc = this.__nsEditor.__dom.doc;\r\n\t\t\tvar container = this.__parentContainer;\r\n\t\t\tvar scrollTop = win.pageYOffset || (doc.documentElement && doc.documentElement.scrollTop) || 0;\r\n\t\t\tvar offsetEditor = this.editorUtil.getOffset(container,true,doc);\r\n\t\t\tvar hasScroll = (scrollTop > offsetEditor.top && scrollTop  < offsetEditor.top + offsetEditor.height);\r\n\t\t\tvar enableInMobile = this.__config.enableStickyToolbarForMobile && this.__isDeviceMobile();\r\n\t\t\tvar performSticky = !this.__isSourceMode && hasScroll && !enableInMobile;\r\n\t\t\tif(this.__config.enableStickyToolbar && this.__config.enableToolBar)\r\n\t\t\t{\r\n\t\t\t\tif(performSticky)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__makeSticky(this.__divToolBarContainer);\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.__removeSticky(this.__divToolBarContainer);\r\n\t\t\t\t}\r\n\t\t\t\tthis.__nsEditor.__dispatchInternalEvent(\"stickyChanged\",{isSticky: performSticky},{isSticky: performSticky});\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__isDeviceMobile = function() \r\n\t\t{\r\n\t\t\treturn false;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__makeSticky = function(comp) \r\n\t\t{\r\n\t\t\tvar container = this.__parentContainer;\r\n\t\t\tif(!this.__isSticked)\r\n\t\t\t{\r\n\t\t\t\tthis.__createDuplicate(comp);\r\n\t\t\t\tthis.util.addStyleClass(container,\"nsEditorSticky\");\r\n\t\t\t\tthis.__isSticked = true;\r\n\t\t\t}\r\n\t\t\tvar style = {top: 0,width: container.offsetWidth};\r\n\t\t\tthis.util.css(comp,style);\r\n\t\t\tif(this.__nsEditor.__browserDetail.isMSIE && this.__compDuplicate)\r\n\t\t\t{\r\n\t\t\t\tstyle = {height: comp.offsetHeight};\r\n\t\t\t\tthis.util.css(this.__compDuplicate,style);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__removeSticky = function(comp) \r\n\t\t{\r\n\t\t\tif(this.__isSticked)\r\n\t\t\t{\r\n\t\t\t\tvar container = this.__parentContainer;\r\n\t\t\t\tvar style = {top: \"\",width: \"\"};\r\n\t\t\t\tthis.util.css(comp,style);\r\n\t\t\t\tthis.util.removeStyleClass(container,\"nsEditorSticky\");\r\n\t\t\t\tthis.__isSticked = false;\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__createDuplicate = function(comp) \r\n\t\t{\r\n\t\t\tif(this.__nsEditor.__browserDetail.isMSIE && !this.__compDuplicate)\r\n\t\t\t{\r\n\t\t\t\tthis.__compDuplicate = this.util.createDiv(null,\"nsEditorStickyToolbar\");\r\n\t\t\t\tcomp.parentNode.insertBefore(this.__compDuplicate,comp);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.isToolbarSticky = function() \r\n\t\t{\r\n\t\t\treturn this.util.hasStyleClass(this.__parentContainer,\"nsEditorSticky\");\r\n\t\t};\r\n\t    \r\n\t    //end of sticky header\r\n\t\t\r\n\t\tthis.__createHorizontalSeparator = function()\r\n\t\t{\r\n\t\t\tvar comp = this.util.createElement(\"span\",null,\"nsEditorToolBarVerticalSeparator\");\r\n\t\t\treturn comp;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__placeElementByEvent = function(element,event,posOffset)\r\n\t\t{\r\n\t\t\tposOffset = posOffset || {left: 0,top: 0};\r\n\t\t\tvar offset = this.util.getEventPosition(event);\r\n\t\t\telement.style.left = (offset.left + (posOffset.left * 1)) + \"px\";\r\n\t\t\telement.style.top = (offset.top + (posOffset.top * 1)) + \"px\";\r\n\t\t};\r\n\t\t\r\n\t\tthis.__initialize();\r\n\t};\r\n\t\t\r\n\treturn NSToolBar;\r\n})();\r\nnsModuleExport(this,\"NSToolBar\",NSToolBar); var NSSelection = (function()\r\n{\r\n\tvar NSSelection = function(nsEditor)\r\n\t{\r\n\t\tthis.__nsEditor = nsEditor;\r\n\t\tthis.util = nsEditor.util;\r\n\t\tthis.editorUtil = nsEditor.editorUtil;\r\n\t\t\r\n\t\tthis.__savedSelection = null;\r\n\t\t\r\n\t\tthis.__initialize = function()\r\n\t\t{\r\n\t\t\t\r\n\t\t};\r\n\t\t\r\n\t\t/* Start of selection function */\r\n\t\tthis.getSelection = function() \r\n\t\t{\r\n\t\t\tif(this.__nsEditor.__isModeTextArea())\r\n\t\t\t{\r\n\t\t\t\tif (this.__nsEditor.__context.getSelection) \r\n\t\t\t\t{\r\n\t\t\t\t\treturn this.__nsEditor.__context.getSelection();\r\n\t\t\t\t} \r\n\t\t\t\telse if (this.__nsEditor.__dom.doc.selection) \r\n\t\t\t\t{\r\n\t\t\t\t   return this.__nsEditor.__dom.doc.selection;\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\tvar contentWindow = this.__nsEditor.__compTextArea.contentWindow;\r\n\t\t\t\tif (contentWindow) \r\n\t\t\t\t{\r\n\t\t\t\t\tif (contentWindow.getSelection) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treturn contentWindow.getSelection();\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (contentWindow.selection) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treturn contentWindow.selection;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tvar doc = this.__frameContentDoc;\r\n\t\t\t\tif (doc.getSelection) \r\n\t\t\t\t{\r\n\t\t\t\t\treturn doc.getSelection();\r\n\t\t\t\t}\r\n\t\t\t\tif (doc.selection) \r\n\t\t\t\t{\r\n\t\t\t\t\treturn doc.selection;\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\r\n\t\t//restore\r\n\t    this.restoreSelection = function(objSaved) \r\n\t\t{\r\n\t    \tobjSaved = objSaved || this.__savedSelection;\r\n\t    \tif(objSaved)\r\n\t    \t{\r\n\t    \t\tif(objSaved instanceof Range)\r\n\t    \t\t{\r\n\t    \t\t\tvar selection = null;\r\n\t\t\t\t\tvar self = this;\r\n\t\t\t\t\tvar setTextRange = function(win,doc)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif(win.getSelection || doc.createRange) \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tselection = win.getSelection();\r\n\t\t\t\t\t        try \r\n\t\t\t\t\t        {\r\n\t\t\t\t\t        \tselection.removeAllRanges();\r\n\t\t\t\t\t        } \r\n\t\t\t\t\t        catch (error) \r\n\t\t\t\t\t        {\r\n\t\t\t\t\t        \tdoc.body.createTextRange().select();\r\n\t\t\t\t\t        \tif(doc.selection)\r\n\t\t\t\t\t        \t{\r\n\t\t\t\t\t        \t\tdoc.selection.empty();\r\n\t\t\t\t\t        \t}\r\n\t\t\t\t\t        }\r\n\t\t\t\t\t        selection.addRange(objSaved);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse if (doc.selection) \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tobjSaved.select();\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\t\tif(this.__nsEditor.__isModeTextArea())\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tsetTextRange(this.__nsEditor.__context,this.__nsEditor.__dom.doc);\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\tsetTextRange(this.__nsEditor.__frameContentWindow,this.__nsEditor.__frameContentDoc);\r\n\t\t\t\t\t}\r\n\t    \t\t}\r\n\t    \t\telse if(this.util.isArray(objSaved))\r\n\t    \t\t{\r\n\t    \t\t\tvar range = null;\r\n\t    \t\t\tfor(var count = 0;count < objSaved.length;count++) \r\n\t\t\t\t\t{\r\n\t    \t\t\t\tvar item = objSaved[count];\r\n\t    \t\t\t\tvar start = item.start;\r\n\t    \t\t\t\tvar end = item.end;\r\n\t    \t\t\t\tif(start) \r\n\t    \t\t\t\t{\r\n\t    \t\t\t\t\trange = this.createRange();\r\n\t    \t\t\t\t\tif(item.collapsed || !end) \r\n\t    \t\t\t\t\t{\r\n\t    \t\t\t\t\t\tvar previousNode = start.previousSibling;\r\n\t    \t\t\t\t\t\tif(this.util.isTextNode(previousNode)) \r\n\t    \t\t\t\t\t\t{\r\n\t    \t\t\t\t\t\t\trange.setStart(previousNode,(previousNode.nodeValue ? previousNode.nodeValue.length : 0));\r\n\t    \t\t\t\t\t\t} \r\n\t    \t\t\t\t\t\telse \r\n\t    \t\t\t\t\t\t{\r\n\t    \t\t\t\t\t\t\trange.setStartBefore(start);\r\n\t    \t\t\t\t\t\t}\r\n\t    \t\t\t\t\t\tthis.editorUtil.removeNode(start);\r\n\t    \t\t\t\t\t\trange.collapse(true);\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\trange.setStartAfter(start);\r\n\t    \t\t\t\t\t\tthis.editorUtil.removeNode(start);\r\n\t    \t\t\t\t\t\trange.setEndBefore(end);\r\n\t    \t\t\t\t\t\tthis.editorUtil.removeNode(end);\r\n\t    \t\t\t\t\t}\r\n\t    \t\t\t\t}\r\n\r\n\t\t\t\t\t}\r\n\t    \t\t\tif(range) \r\n\t    \t\t\t{\r\n\t    \t\t\t\tthis.selectRange(range);\r\n\t    \t\t\t}\r\n\t    \t\t}\r\n\t    \t}\r\n\t\t};\r\n\t\t\r\n\t\t//save\r\n\t\tthis.saveSelection = function(saveSelection,wrapText)\r\n\t\t{\r\n\t\t\tsaveSelection = (saveSelection == null) ? true : Boolean.parse(saveSelection);\r\n\t\t\tvar savedSelection = null;\r\n\t\t\tif(wrapText)\r\n\t\t\t{\r\n\t\t\t\tsavedSelection = [];\r\n\t\t\t\tvar selection = this.getSelection();\r\n\t\t\t\tif(selection && selection.rangeCount) \r\n\t\t\t\t{\r\n\t\t\t\t\tvar ranges = [];\r\n\t\t\t\t\tvar rangeCount = selection.rangeCount;\r\n\t\t\t\t\tvar start = null;\r\n\t\t\t\t\tvar end = null;\r\n\t\t\t\t\tfor(var count = 0;count < rangeCount;count++) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tranges[count] = selection.getRangeAt(count);\r\n\t\t\t\t\t\tif (ranges[count].collapsed) \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tstart = this.__createWrapper(true,ranges[count]);\r\n\t\t\t\t\t\t\tsavedSelection[count] = {start:start,collapsed:true,startMarker: start.outerHTML};\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\tstart = this.__createWrapper(true,ranges[count]);\r\n\t\t\t\t\t\t\tend = this.__createWrapper(false,ranges[count]);\r\n\t\t\t\t\t\t\tsavedSelection[count]  = {start: start,end: end,collapsed: false,startMarker: start.outerHTML,endMarker: end.outerHTML};\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tselection.removeAllRanges();\r\n\t\t\t\t\tfor(var count = rangeCount - 1;count > -1; --count) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar start = savedSelection[count].start;\r\n\t\t\t\t\t\tif(start) \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif(savedSelection[count].collapsed) \r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tranges[count].setStartAfter(start);\r\n\t\t\t\t\t\t\t\tranges[count].collapse(true);\r\n\t\t\t\t\t\t\t} \r\n\t\t\t\t\t\t\telse \r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t//doing setStartAfter as with setStartBefore the element added gets added before the start selection span\r\n\t\t\t\t\t\t\t\t//ranges[count].setStartBefore(start);\r\n\t\t\t\t\t\t\t\tranges[count].setStartAfter(start);\r\n\t\t\t\t\t\t\t\tif(savedSelection[count].end) \r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tvar end = savedSelection[count].end;\r\n\t\t\t\t\t\t\t\t\tif(end) \r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t//doing setEndBefore as with setEndAfter the element added wraps after the end selection span\r\n\t\t\t\t\t\t\t\t\t\t//ranges[count].setEndAfter(end);\r\n\t\t\t\t\t\t\t\t\t\tranges[count].setEndBefore(end);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\ttry \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tselection.addRange(ranges[count].cloneRange());\r\n\t\t\t\t\t\t} \r\n\t\t\t\t\t\tcatch(error)\r\n\t\t\t\t\t\t{\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\telse \r\n\t\t\t{\r\n\t\t\t\tsavedSelection = this.getRange();\r\n\t\t\t}\r\n\t\t\tif(saveSelection)\r\n\t\t\t{\r\n\t\t\t\tthis.__savedSelection = savedSelection;\r\n\t\t\t}\r\n\t\t\treturn savedSelection;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__createWrapper = function(isStart,range)\r\n\t\t{\r\n\t\t\tvar clonedRange;\r\n\t\t\tvar doc = this.__nsEditor.__getDocument();\r\n\t\t\tvar textArea = this.__nsEditor.__getTextArea();\r\n\t\t\tif (range) \r\n\t\t\t{\r\n\t\t\t\tclonedRange = range.cloneRange();\r\n\t\t\t\tclonedRange.collapse(isStart);\r\n\t\t\t}\r\n\t\t\tvar wrapper = this.util.createElement(\"span\",null,\"nsEditorSelectionWrapper nsEditorSelectionWrapper\" + (isStart ? \"Start\" : \"End\"),doc);\r\n\t\t\tthis.util.css(wrapper,{lineHeight: 0,display:\"none\"});\r\n\t\t\twrapper.appendChild(doc.createTextNode(this.editorUtil.INVISIBLE_SPACE));\r\n\t\t\tif(clonedRange) \r\n\t\t\t{\r\n\t\t\t\tif (this.editorUtil.isExistsInsideEditor(isStart ? clonedRange.startContainer : clonedRange.endContainer)) \r\n\t\t\t\t{\r\n\t\t\t\t\tclonedRange.insertNode(wrapper);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\treturn wrapper;\r\n\t\t};\r\n\t\t\r\n\t\t//isMarker\r\n\t\tthis.isSelectionWrapper = function(node)\r\n\t\t{\r\n\t\t\tnode && this.util.hasStyleClass(node,\"nsEditorSelectionWrapper\");\r\n\t\t}\r\n\t\t\r\n\t\t/* end of selection function */\r\n\t\t\r\n\t\t/* Start of range function */\r\n\t\t\r\n\t\tthis.getRange = function() \r\n\t\t{\r\n\t\t\tvar selection = this.getSelection();\r\n\t\t\tif (selection) \r\n\t\t\t{\r\n\t\t\t\tif (selection.rangeCount && selection.rangeCount > 0) \r\n\t\t\t\t{\r\n\t\t\t\t\treturn selection.getRangeAt(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\treturn this.createRange();\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\r\n\t\tthis.createRange = function() \r\n\t\t{\r\n\t\t\tvar doc = this.__nsEditor.__getDocument();\r\n\t\t\tvar range = doc.createRange();\r\n\t\t\treturn range;\r\n\t\t};\r\n\t\t\r\n\t\tthis.selectRange = function(range,focus) \r\n\t\t{\r\n\t\t\tfocus = this.util.isUndefinedOrNull(focus) ? true : Boolean.parse(focus);\r\n\t\t\tif(focus && !this.hasFocus()) \r\n\t\t\t{\r\n\t\t\t\tthis.setFocus();\r\n\t\t\t}\r\n\t\t\tvar selection = this.getSelection();\r\n\t\t\tif (selection) \r\n\t\t\t{\r\n\t\t\t\tselection.removeAllRanges();\r\n\t\t\t\tselection.addRange(range);\r\n\t\t\t}\r\n\t\t\tthis.__nsEditor.__dispatchInternalEvent(\"selectionchange\",{range:range},{range:range});\r\n\t\t};\r\n\t\t\r\n\t\t//select\r\n\t\tthis.selectElement = function(node,isInward) \r\n\t\t{\r\n\t\t\tif(node)\r\n\t\t\t{\r\n\t\t\t\tisInward = Boolean.parse(isInward);\r\n\t\t\t\tvar isExistsInside = this.editorUtil.isExistsInsideEditor(node);\r\n\t\t\t\tif(isExistsInside)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar range = this.createRange();\r\n\t\t\t\t    range[isInward ? \"selectNodeContents\" : \"selectNode\"](node);\r\n\t\t\t\t    this.selectRange(range);\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.warning(\"NSEditor\",\"Node element must be in editor\");\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.createDefaultRange = function() \r\n\t    {\r\n\t\t\tthis.setFocus();\r\n\t        var range = this.createRange();\r\n\t        var body = this.__nsEditor.__getTextArea();\r\n\t        var focusElement = body.firstElementChild;\r\n\t        if (!focusElement) \r\n\t        {\r\n\t        \tbody.innerHTML = this.__config.defaultValue;\r\n\t        \tfocusElement = body.firstElementChild;\r\n\t        }\r\n\t        range.setStart(focusElement, 0);\r\n\t        range.setEnd(focusElement, 0);\r\n\t        return range;\r\n\t    };\r\n\t\t\r\n\t\t/* end of range function */\r\n\t\t\r\n\t\tthis.insertNode = function(node,insertCursorAfter,checkCharCount) \r\n\t\t{\r\n\t\t\tif(node)\r\n\t\t\t{\r\n\t\t\t\tcheckCharCount = this.util.isUndefinedOrNull(checkCharCount) ? true : Boolean.parse(checkCharCount);\r\n\t\t\t\tif (!this.__nsEditor.__checkCharCount(node, null)) \r\n\t\t\t\t{\r\n\t            \treturn false;\r\n\t        \t}\r\n\t\t\t\tinsertCursorAfter = this.util.isUndefinedOrNull(insertCursorAfter) ? true : Boolean.parse(insertCursorAfter);\r\n\t\t\t\tif (!this.hasFocus() && !this.__nsEditor.__isSourceMode) \r\n\t\t        {\r\n\t\t\t\t\t//this.restoreSelection();\r\n\t\t            this.setFocus();\r\n\t\t        }\r\n\t\t\t\tif (!this.isCollapsed()) \r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__nsEditor.__executeCommand(\"Delete\");\r\n\t\t\t\t}\r\n\t\t\t\tvar tempNode = null;\r\n\t\t\t\tvar selection = this.getSelection();\r\n\t\t\t\tvar textArea = this.__nsEditor.__getTextArea();\r\n\t\t\t\tif(selection && selection.rangeCount)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar range = selection.getRangeAt(0);\r\n\t\t\t\t\tif (this.util.isElementInOrParent(range.commonAncestorContainer,textArea)) \r\n\t\t\t\t\t{\r\n\t\t\t                if (/^(BR|HR|IMG|VIDEO)$/i.test(range.startContainer.nodeName) && range.collapsed) \r\n\t\t\t                {\r\n\t\t\t                \ttempNode = range.startContainer.parentNode;\r\n\t\t\t                \tif(tempNode)\r\n\t\t\t                \t{\r\n\t\t\t                \t\ttempNode.insertBefore(node, range.startContainer);\r\n\t\t\t                \t}\r\n\t\t\t                }\r\n\t\t\t                else \r\n\t\t\t                {\r\n\t\t\t                    range.deleteContents();\r\n\t\t\t                    range.insertNode(node);\r\n\t\t\t                }\r\n\t\t            }\r\n\t\t            else \r\n\t\t            {\r\n\t\t            \ttextArea.appendChild(node);\r\n\t\t            }\r\n\t\t\t\t}\r\n\t\t\t\telse \r\n\t            {\r\n\t            \ttextArea.appendChild(node);\r\n\t            }\r\n\t\t\t\tif (insertCursorAfter) \r\n\t\t\t\t{\r\n\t\t            if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) \r\n\t\t            {\r\n\t\t            \tif(node.lastChild)\r\n\t\t            \t{\r\n\t\t            \t\tthis.setCursorAfter(node.lastChild);\r\n\t\t            \t}\r\n\t\t            }\r\n\t\t            else \r\n\t\t            {\r\n\t\t                this.setCursorAfter(node);\r\n\t\t            }\r\n\t\t        }\r\n\t\t\t\tthis.__nsEditor.__dispatchInternalEvent(\"insertedNode\");\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t    };\r\n\t    \r\n\t    this.insertHTML = function(html) \r\n\t    {\r\n\t        if (html) \r\n\t        {\r\n\t        \tvar doc = this.__nsEditor.__getDocument();\r\n\t        \tvar textArea = this.__nsEditor.__getTextArea(); \r\n\t        \tvar divTemp = doc.createElement(\"div\");\r\n\t        \tvar fragment = doc.createDocumentFragment();\r\n\t\t        if (!this.hasFocus() && !this.__isSourceMode) \r\n\t\t        {\r\n\t\t            this.setFocus();\r\n\t\t        }\r\n\t\t        if (!this.editorUtil.isNode(html)) \r\n\t\t        {\r\n\t\t            divTemp.innerHTML = html.toString();\r\n\t\t        }\r\n\t\t        else \r\n\t\t        {\r\n\t\t            divTemp.appendChild(html);\r\n\t\t        }\r\n\t\t        var lastChild = divTemp.lastChild;\r\n\t\t        if (this.__isSourceMode || !lastChild) \r\n\t\t        {\r\n\t\t            return;\r\n\t\t        }\r\n\t\t        while (divTemp.firstChild) \r\n\t\t        {\r\n\t\t            lastChild = divTemp.firstChild;\r\n\t\t            fragment.appendChild(divTemp.firstChild);\r\n\t\t        }\r\n\t\t        if(this.insertNode(fragment, false))\r\n\t\t        {\r\n\t\t        \tif (lastChild) \r\n\t\t        \t{\r\n\t\t\t            this.setCursorAfter(lastChild);\r\n\t\t\t        }\r\n\t\t\t        else \r\n\t\t\t        {\r\n\t\t\t            this.setCursorIn(fragment);\r\n\t\t\t        }\r\n\t\t\t        var lastEditorElement = textArea.lastChild;\r\n\t\t\t        while(this.util.isTextNode(lastEditorElement) && lastEditorElement.previousSibling && lastEditorElement.nodeValue &&\r\n\t\t\t            /^\\s*$/.test(lastEditorElement.nodeValue)) \r\n\t\t\t        {\r\n\t\t\t            lastEditorElement = lastEditorElement.previousSibling;\r\n\t\t\t        }\r\n\t\t\t        if (lastChild) \r\n\t\t\t        {\r\n\t\t\t            if (lastEditorElement && lastChild === lastEditorElement &&\r\n\t\t\t            \t\tthis.util.isElement(lastChild)) \r\n\t\t\t            {\r\n\t\t\t            \ttextArea.appendChild(doc.createElement(\"br\"));\r\n\t\t\t            }\r\n\t\t\t            this.setCursorAfter(lastChild);\r\n\t\t\t        }\r\n\t\t        }\r\n\t\t        \r\n\t        }\r\n\t    };\r\n\t\t\r\n\t\t//remove\r\n\t\tthis.removeSelectedContent = function() \r\n\t\t{\r\n\t\t\tvar selection = this.getSelection();\r\n\t\t\tvar element = this.getElementUnderCursor();\r\n\t\t\tif (selection && element) \r\n\t\t\t{\r\n\t\t\t\tfor (var count = 0;count < selection.rangeCount; count++) \r\n\t\t\t\t{\r\n\t\t\t\t\tselection.getRangeAt(count).deleteContents();\r\n\t\t\t\t\tselection.getRangeAt(count).collapse(true);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\r\n\t\tthis.removeNode = function(node)\r\n\t\t{\r\n\t\t\tvar isExistsInside = this.editorUtil.isExistsInsideEditor(node);\r\n    \t\tif(isExistsInside)\r\n\t\t\t{\r\n    \t\t\tthis.editorUtil.removeNode(node);\r\n\t\t\t}\r\n    \t\t//afterRemoveNode\r\n    \t\tthis.__nsEditor.__dispatchInternalEvent(\"removedNode\",{node: node},{node: node});\r\n\t\t};\r\n\t\t\r\n\t\tthis.insertCursorAtPoint = function (xPos,yPos) \r\n\t\t{\r\n\t        var self = this;\r\n\t        this.removeMarkers();\r\n\t        try \r\n\t        {\r\n\t        \tvar doc = this.__nsEditor.__getDocument();\r\n\t        \tvar range = this.createRange();\r\n\t        \tif(doc.caretPositionFromPoint) \r\n\t        \t{\r\n                    var caret = doc.caretPositionFromPoint(xPos,yPos);\r\n                    if (caret) \r\n                    {\r\n                        range.setStart(caret.offsetNode,caret.offset);\r\n                    }\r\n                }\r\n\t        \telse if(doc.caretRangeFromPoint) \r\n                {\r\n                    var caret = doc.caretRangeFromPoint(xPos,yPos);\r\n                    range.setStart(caret.startContainer, caret.startOffset);\r\n                }\r\n\t            range.collapse(true);\r\n\t            this.selectRange(range);\r\n\t            return true;\r\n\t        }\r\n\t        catch (error) \r\n\t        { \r\n\t        \t\r\n\t        }\r\n\t        return false;\r\n\t    };\r\n\t    \r\n\t    this.isCollapsed = function() \r\n\t    {\r\n\t        var selection = this.getSelection();\r\n\t        if(selection)\r\n\t        {\r\n\t        \tfor (var count = 0; count < selection.rangeCount; count++) \r\n\t\t        {\r\n\t\t            if (!selection.getRangeAt(count).collapsed) \r\n\t\t            {\r\n\t\t                return false;\r\n\t\t            }\r\n\t\t        }\r\n\t        }\r\n\t        return true;\r\n\t    };\r\n\t    \r\n\t    //isFocused\r\n\t    this.hasFocus = function () \r\n\t    {\r\n\t    \tvar doc = this.__nsEditor.__getDocument();\r\n\t    \tvar textArea = this.__nsEditor.__getTextArea(); \r\n\t        return (doc.hasFocus && doc.hasFocus() && textArea === doc.activeElement);\r\n\t    };\r\n\t    \r\n\t    this.setFocus = function() \r\n\t\t{\r\n\t\t\tif(this.__nsEditor.__isModeTextArea())\r\n\t\t\t{\r\n\t\t\t\tthis.__nsEditor.__compTextArea && this.__nsEditor.__compTextArea.focus();\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthis.__nsEditor.__frameContentWindow && this.__nsEditor.__frameContentWindow.focus();\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\t//current\r\n\t\tthis.getElementUnderCursor = function(parseChildren)\r\n\t\t{\r\n\t\t\tparseChildren = this.util.isUndefinedOrNull(parseChildren) ? true : Boolean.parse(parseChildren);\r\n\t        if (!this.__nsEditor.__isSourceMode) \r\n\t        {\r\n\t            var selection = this.getSelection();\r\n\t            if (selection && selection.rangeCount > 0) \r\n\t            {\r\n\t                var range = selection.getRangeAt(0);\r\n\t                var node = range.startContainer\r\n\t                var isRight = false;\r\n\t                var getChild = function(paramNode) \r\n\t                {\r\n\t                    return isRight ? paramNode.lastChild : paramNode.firstChild;\r\n\t                };\r\n\t                if (!this.util.isTextNode(node)) \r\n\t                {\r\n\t                    node = range.startContainer.childNodes[range.startOffset];\r\n\t                    if (!node) \r\n\t                    {\r\n\t                        node = range.startContainer.childNodes[range.startOffset - 1];\r\n\t                        isRight = true;\r\n\t                    }\r\n\t                    if (node && selection.isCollapsed && !this.util.isTextNode(node)) \r\n\t                    {\r\n\t                        if (!isRight && this.util.isTextNode(node.previousSibling)) \r\n\t                        {\r\n\t                            node = node.previousSibling;\r\n\t                        }\r\n\t                        else if (parseChildren) \r\n\t                        {\r\n\t                            var current = getChild(node);\r\n\t                            while (current) \r\n\t                            {\r\n\t                                if (current && this.util.isTextNode(current)) \r\n\t                                {\r\n\t                                    node = current;\r\n\t                                    break;\r\n\t                                }\r\n\t                                current = getChild(current);\r\n\t                            }\r\n\t                        }\r\n\t                    }\r\n\t                    if (node && !selection.isCollapsed && !this.util.isTextNode(node)) \r\n\t                    {\r\n\t                        var leftChild = node;\r\n\t                        var rightChild = node;\r\n\t                        do \r\n\t                        {\r\n\t                            leftChild = leftChild.firstChild;\r\n\t                            rightChild = rightChild.lastChild;\r\n\t                        } \r\n\t                        while (leftChild && rightChild && !this.util.isTextNode(leftChild));\r\n\t                        if (leftChild === rightChild && leftChild && this.util.isTextNode(leftChild)) \r\n\t                        {\r\n\t                            node = leftChild;\r\n\t                        }\r\n\t                    }\r\n\t                }\r\n\t                var isExistsInside = this.editorUtil.isExistsInsideEditor(node);\r\n\t                if (node && isExistsInside) \r\n\t                {\r\n\t                    return node;\r\n\t                }\r\n\t            }\r\n\t        }\r\n\t        return null;\r\n\t\t};\r\n\t\t\r\n\t\tthis.setCursorAfter = function(node) \r\n\t\t{\r\n\t    \tif(node)\r\n\t    \t{\r\n\t    \t\tvar isExistsInside = this.editorUtil.isExistsInsideEditor(node);\r\n\t\t\t\tif(isExistsInside)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar range = this.createRange();\r\n\t\t\t\t\tvar fakeNode = null;\r\n\t\t\t        if (!this.util.isTextNode(node)) \r\n\t\t\t        {\r\n\t\t\t            fakeNode = this.__nsEditor.__dom.doc.createTextNode(\"\");\r\n\t\t\t            range.setStartAfter(node);\r\n\t\t\t            range.insertNode(fakeNode);\r\n\t\t\t            range.selectNode(fakeNode);\r\n\t\t\t        }\r\n\t\t\t        else \r\n\t\t\t        {\r\n\t\t\t            range.setEnd(node, node.nodeValue !== null ? node.nodeValue.length : 0);\r\n\t\t\t        }\r\n\t\t\t        range.collapse(false);\r\n\t\t\t\t\tthis.selectRange(range);\r\n\t\t\t\t\treturn fakeNode;\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.warning(\"NSEditor\",\"Node element must be in editor\");\r\n\t\t\t\t}\r\n\t    \t}\r\n\t    \treturn null;\r\n\t\t};\r\n\t\t\r\n\t\tthis.setCursorBefore = function(node) \r\n\t\t{\r\n\t    \tif(node)\r\n\t    \t{\r\n\t    \t\tvar isExistsInside = this.editorUtil.isExistsInsideEditor(node);\r\n\t\t\t\tif(isExistsInside)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar range = this.createRange();\r\n\t\t\t\t\tvar fakeNode = null;\r\n\t\t\t        if (!this.util.isTextNode(node)) \r\n\t\t\t        {\r\n\t\t\t            fakeNode = this.__nsEditor.__dom.doc.createTextNode(\"\");\r\n\t\t\t            range.setStartAfter(node);\r\n\t\t\t            range.collapse(true);\r\n\t\t\t            range.insertNode(fakeNode);\r\n\t\t\t            range.selectNode(fakeNode);\r\n\t\t\t        }\r\n\t\t\t        else \r\n\t\t\t        {\r\n\t\t\t            range.setStart(node, node.nodeValue !== null ? node.nodeValue.length : 0);\r\n\t\t\t        }\r\n\t\t\t        range.collapse(true);\r\n\t\t\t\t\tthis.selectRange(range);\r\n\t\t\t\t\treturn fakeNode;\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.warning(\"NSEditor\",\"Node element must be in editor\");\r\n\t\t\t\t}\r\n\t    \t}\r\n\t    \treturn null;\r\n\t\t};\r\n\t\t\r\n\t\tthis.setCursorIn = function(node,inStart) \r\n\t\t{\r\n\t    \tif(node)\r\n\t    \t{\r\n\t    \t\tinStart = this.util.isUndefinedOrNull(inStart) ? true : Boolean.parse(inStart);\r\n\t    \t\tvar isExistsInside = this.editorUtil.isExistsInsideEditor(node);\r\n\t\t\t\tif(isExistsInside)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar range = this.createRange();\r\n\t\t\t\t\tvar startNode = node;\r\n\t\t\t\t\tvar lastNode = node;\r\n\t\t\t\t\tdo \r\n\t\t\t\t\t{\r\n\t\t\t            if(this.util.isTextNode(startNode)) \r\n\t\t\t            {\r\n\t\t\t                break;\r\n\t\t\t            }\r\n\t\t\t            lastNode = startNode;\r\n\t\t\t            startNode = inStart ? startNode.firstChild : startNode.lastChild;\r\n\t\t\t        } \r\n\t\t\t\t\twhile (startNode);\r\n\t\t\t\t\tif (!startNode) \r\n\t\t\t\t\t{\r\n\t\t\t            var fakeNode = this.__nsEditor.__dom.doc.createTextNode(\"\");\r\n\t\t\t            if (!/^(img|br|input)$/i.test(lastNode.nodeName)) \r\n\t\t\t            {\r\n\t\t\t            \tlastNode.appendChild(fakeNode);\r\n\t\t\t            \tlastNode = fakeNode;\r\n\t\t\t            }\r\n\t\t\t            else \r\n\t\t\t            {\r\n\t\t\t            \tstartNode = lastNode;\r\n\t\t\t            }\r\n\t\t\t        }\r\n\t\t\t\t\trange.selectNodeContents(startNode || lastNode);\r\n\t\t\t        range.collapse(inStart);\r\n\t\t\t        this.selectRange(range);\r\n\t\t\t        return lastNode;\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.warning(\"NSEditor\",\"Node element must be in editor\");\r\n\t\t\t\t}\r\n\t    \t}\r\n\t    \treturn null;\r\n\t\t};\r\n\t\t\r\n\t\t//getHTML\r\n\t\tthis.getSelectedHTML = function() \r\n\t\t{\r\n\t\t\tvar selection = this.getSelection();\r\n\t        if (selection && selection.rangeCount > 0) \r\n\t        {\r\n\t        \tvar doc = this.__nsEditor.__getDocument();\r\n\t            var range = selection.getRangeAt(0);\r\n\t            var clonedSelection = range.cloneContents();\r\n\t            var div = doc.createElement(\"div\");\r\n\t            div.appendChild(clonedSelection);\r\n\t            return div.innerHTML;\r\n\t        }\r\n\t        return \"\";\r\n\t    };\r\n\t    \r\n\t    this.getSelectedNodes = function()\r\n\t    {\r\n\t    \tvar selection = this.getSelection();\r\n\t        if (selection && selection.rangeCount > 0) \r\n\t        {\r\n\t        \tvar self = this;\r\n\t        \tvar arrNodes = [];\r\n\t        \tvar doc = this.__nsEditor.__getDocument();\r\n\t        \tvar textArea = this.__nsEditor.__getTextArea();\r\n\t        \tvar range = selection.getRangeAt(0);\r\n\t        \tvar arrChild = textArea.childNodes;\r\n\t        \tvar elementOffset = (range.startOffset < arrChild.length) ? range.startOffset : arrChild.length - 1;\r\n\t        \tvar start = (range.startContainer == textArea)? arrChild[elementOffset] : range.startContainer;\r\n\t            var end = (range.endContainer == textArea) ? arrChild[range.endOffset - 1] : range.endContainer;\r\n\t            var callback = function(node)\r\n\t            {\r\n\t            \tif(node && node != textArea && !self.editorUtil.isEmptyTextNode(node) && !self.isSelectionWrapper(node))\r\n\t            \t{\r\n\t            \t\tarrNodes.push(node);\r\n                    }\r\n                    var retValue =  (node == end || (node && node.contains && node.contains(end)));\r\n                    return retValue;\r\n\t            };\r\n\t            this.util.findNode(start,callback,textArea,true,\"nextSibling\",\"\");\r\n\t            if (arrNodes.length === 0 && this.editorUtil.isEmptyTextNode(start)) \r\n\t            {\r\n\t            \tarrNodes.push(start);\r\n\t            }\r\n\t            return arrNodes;\r\n\t        }\r\n\t        return null;\r\n\t    };\r\n\t    \r\n\t  //eachSelection\r\n\t    this.loopSelectedNodes = function(callback)\r\n\t    {\r\n\t    \tif(callback)\r\n\t    \t{\r\n\t    \t\tvar arrNodes = this.getSelectedNodes();\r\n\t\t    \tif(arrNodes && arrNodes.length)\r\n\t\t    \t{\r\n\t\t    \t\tvar doc = this.__nsEditor.__getDocument();\r\n\t\t    \t\tvar textArea = this.__nsEditor.__getTextArea();\r\n\t\t    \t\tvar self = this;\r\n\t\t    \t\tvar callbackNode = function(node)\r\n\t\t    \t\t{\r\n\t\t    \t\t\tif (node != textArea && self.editorUtil.isExistsInsideEditor(node)) \r\n\t\t    \t\t\t{\r\n\t\t    \t\t\t\tif(node.nodeName.match(/^(UL|OL)$/)) \r\n\t\t    \t\t\t\t{\r\n\t\t                        var arrChild = Array.from(node.childNodes);\r\n\t\t                        if(arrChild && arrChild.length)\r\n\t\t                        {\r\n\t\t                        \tfor(var count = 0;count < arrChild.length;count++)\r\n\t\t                        \t{\r\n\t\t                        \t\tcallbackNode(arrChild);\r\n\t\t                        \t}\r\n\t\t                        }\r\n\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\tif(self.util.isElementOfType(node,\"li\"))\r\n\t\t    \t\t\t\t\t{\r\n\t\t    \t\t\t\t\t\tif (node.firstChild) \r\n\t\t    \t\t\t\t\t\t{\r\n\t\t\t                            node = node.firstChild;\r\n\t\t\t                        }\r\n\t\t\t                        else \r\n\t\t\t                        {\r\n\t\t\t                            var tempNode = doc.createTextNode(\"\\uFEFF\");\r\n\t\t\t                            node.appendChild(tempNode);\r\n\t\t\t                            node = tempNode;\r\n\t\t\t                        }\r\n\t\t    \t\t\t\t\t}\r\n\t\t    \t\t\t\t\tcallback(node);\r\n\t\t    \t\t\t\t}\r\n\t                    }\r\n\t\t    \t\t};\r\n\t\t    \t\tfor(count = 0;count < arrNodes.length;count++)\r\n\t\t    \t\t{\r\n\t\t    \t\t\tvar node = arrNodes[count];\r\n\t\t    \t\t\tcallbackNode(node);\r\n\t\t    \t\t}\r\n\t\t    \t}\r\n\t    \t}\r\n\t    };\r\n\t    \r\n\t    /*Select.prototype.wrapInTag = function (tagOrCallback) {\r\n\t        var _this = this;\r\n\t        selector_1.$$('*[style*=font-size]', this.area).forEach(function (elm) {\r\n\t            elm.style &&\r\n\t                elm.style.fontSize &&\r\n\t                elm.setAttribute('data-font-size', elm.style.fontSize.toString());\r\n\t        });\r\n\t        this.doc.execCommand('fontsize', false, '7');\r\n\t        selector_1.$$('*[data-font-size]', this.area).forEach(function (elm) {\r\n\t            var fontSize = elm.getAttribute('data-font-size');\r\n\t            if (elm.style && fontSize) {\r\n\t                elm.style.fontSize = fontSize;\r\n\t                elm.removeAttribute('data-font-size');\r\n\t            }\r\n\t        });\r\n\t        var result = [];\r\n\t        selector_1.$$('font[size=\"7\"]', this.area).forEach(function (font) {\r\n\t            try {\r\n\t                if (checker_1.isFunction(tagOrCallback)) {\r\n\t                    tagOrCallback(font);\r\n\t                }\r\n\t                else {\r\n\t                    result.push(Dom_1.Dom.replace(font, tagOrCallback, _this.jodit.create.inside));\r\n\t                }\r\n\t            }\r\n\t            finally {\r\n\t                if (font.parentNode) {\r\n\t                    Dom_1.Dom.unwrap(font);\r\n\t                }\r\n\t            }\r\n\t        });\r\n\t        return result;\r\n\t    };\r\n\t    Select.prototype.applyCSS = function (cssRules, nodeName, options) {\r\n\t        var _this = this;\r\n\t        if (nodeName === void 0) { nodeName = 'span'; }\r\n\t        var WRAP = 1, UNWRAP = 0, defaultTag = 'SPAN';\r\n\t        var mode;\r\n\t        var findNextCondition = function (elm) {\r\n\t            return elm !== null &&\r\n\t                !Dom_1.Dom.isEmptyTextNode(elm) &&\r\n\t                !_this.isMarker(elm);\r\n\t        };\r\n\t        var checkCssRulesFor = function (elm) {\r\n\t            return (!Dom_1.Dom.isTag(elm, 'font') &&\r\n\t                Dom_1.Dom.isElement(elm) &&\r\n\t                ((checker_1.isPlainObject(options) &&\r\n\t                    each_1.each(options, function (cssPropertyKey, cssPropertyValues) {\r\n\t                        var value = css_1.css(elm, cssPropertyKey, undefined, true);\r\n\t                        return (value !== null &&\r\n\t                            value !== '' &&\r\n\t                            cssPropertyValues.indexOf(value.toString().toLowerCase()) !== -1);\r\n\t                    })) ||\r\n\t                    (typeof options === 'function' && options(_this.jodit, elm))));\r\n\t        };\r\n\t        var isSuitElement = function (elm) {\r\n\t            if (!elm) {\r\n\t                return false;\r\n\t            }\r\n\t            var reg = RegExp('^' + elm.nodeName + '$', 'i');\r\n\t            return ((reg.test(nodeName) ||\r\n\t                !!(options && checkCssRulesFor(elm))) &&\r\n\t                findNextCondition(elm));\r\n\t        };\r\n\t        var toggleStyles = function (elm) {\r\n\t            if (isSuitElement(elm)) {\r\n\t                if (elm.nodeName === defaultTag && cssRules) {\r\n\t                    Object.keys(cssRules).forEach(function (rule) {\r\n\t                        if (mode === UNWRAP ||\r\n\t                            css_1.css(elm, rule) ===\r\n\t                                normalize_1.normilizeCSSValue(rule, cssRules[rule])) {\r\n\t                            css_1.css(elm, rule, '');\r\n\t                            if (mode === undefined) {\r\n\t                                mode = UNWRAP;\r\n\t                            }\r\n\t                        }\r\n\t                        else {\r\n\t                            css_1.css(elm, rule, cssRules[rule]);\r\n\t                            if (mode === undefined) {\r\n\t                                mode = WRAP;\r\n\t                            }\r\n\t                        }\r\n\t                    });\r\n\t                }\r\n\t                if (!Dom_1.Dom.isBlock(elm, _this.win) &&\r\n\t                    (!elm.getAttribute('style') || elm.nodeName !== defaultTag)) {\r\n\t                    Dom_1.Dom.unwrap(elm);\r\n\t                    if (mode === undefined) {\r\n\t                        mode = UNWRAP;\r\n\t                    }\r\n\t                }\r\n\t            }\r\n\t        };\r\n\t        if (this.isCollapsed()) {\r\n\t            var clearStyle = false;\r\n\t            if (this.current() &&\r\n\t                Dom_1.Dom.closest(this.current(), nodeName, this.area)) {\r\n\t                clearStyle = true;\r\n\t                var closest = Dom_1.Dom.closest(this.current(), nodeName, this.area);\r\n\t                if (closest) {\r\n\t                    this.setCursorAfter(closest);\r\n\t                }\r\n\t            }\r\n\t            if (nodeName.toUpperCase() === defaultTag || !clearStyle) {\r\n\t                var node = this.jodit.create.inside.element(nodeName);\r\n\t                node.appendChild(this.jodit.create.inside.text(consts.INVISIBLE_SPACE));\r\n\t                this.insertNode(node, false, false);\r\n\t                if (nodeName.toUpperCase() === defaultTag && cssRules) {\r\n\t                    css_1.css(node, cssRules);\r\n\t                }\r\n\t                this.setCursorIn(node);\r\n\t                return;\r\n\t            }\r\n\t        }\r\n\t        var selInfo = this.save();\r\n\t        normalize_1.normalizeNode(this.area.firstChild);\r\n\t        this.wrapInTag(function (font) {\r\n\t            if (!Dom_1.Dom.next(font, findNextCondition, font.parentNode) &&\r\n\t                !Dom_1.Dom.prev(font, findNextCondition, font.parentNode) &&\r\n\t                isSuitElement(font.parentNode) &&\r\n\t                font.parentNode !== _this.area &&\r\n\t                (!Dom_1.Dom.isBlock(font.parentNode, _this.win) ||\r\n\t                    consts.IS_BLOCK.test(nodeName))) {\r\n\t                toggleStyles(font.parentNode);\r\n\t                return;\r\n\t            }\r\n\t            if (font.firstChild &&\r\n\t                !Dom_1.Dom.next(font.firstChild, findNextCondition, font) &&\r\n\t                !Dom_1.Dom.prev(font.firstChild, findNextCondition, font) &&\r\n\t                isSuitElement(font.firstChild)) {\r\n\t                toggleStyles(font.firstChild);\r\n\t                return;\r\n\t            }\r\n\t            if (Dom_1.Dom.closest(font, isSuitElement, _this.area)) {\r\n\t                var leftRange = _this.createRange(), wrapper = Dom_1.Dom.closest(font, isSuitElement, _this.area);\r\n\t                leftRange.setStartBefore(wrapper);\r\n\t                leftRange.setEndBefore(font);\r\n\t                var leftFragment = leftRange.extractContents();\r\n\t                if ((!leftFragment.textContent ||\r\n\t                    !string_1.trim(leftFragment.textContent).length) &&\r\n\t                    leftFragment.firstChild) {\r\n\t                    Dom_1.Dom.unwrap(leftFragment.firstChild);\r\n\t                }\r\n\t                if (wrapper.parentNode) {\r\n\t                    wrapper.parentNode.insertBefore(leftFragment, wrapper);\r\n\t                }\r\n\t                leftRange.setStartAfter(font);\r\n\t                leftRange.setEndAfter(wrapper);\r\n\t                var rightFragment = leftRange.extractContents();\r\n\t                if ((!rightFragment.textContent ||\r\n\t                    !string_1.trim(rightFragment.textContent).length) &&\r\n\t                    rightFragment.firstChild) {\r\n\t                    Dom_1.Dom.unwrap(rightFragment.firstChild);\r\n\t                }\r\n\t                Dom_1.Dom.after(wrapper, rightFragment);\r\n\t                toggleStyles(wrapper);\r\n\t                return;\r\n\t            }\r\n\t            var needUnwrap = [];\r\n\t            var firstElementSuit;\r\n\t            if (font.firstChild) {\r\n\t                Dom_1.Dom.find(font.firstChild, function (elm) {\r\n\t                    if (elm && isSuitElement(elm)) {\r\n\t                        if (firstElementSuit === undefined) {\r\n\t                            firstElementSuit = true;\r\n\t                        }\r\n\t                        needUnwrap.push(elm);\r\n\t                    }\r\n\t                    else {\r\n\t                        if (firstElementSuit === undefined) {\r\n\t                            firstElementSuit = false;\r\n\t                        }\r\n\t                    }\r\n\t                    return false;\r\n\t                }, font, true);\r\n\t            }\r\n\t            needUnwrap.forEach(Dom_1.Dom.unwrap);\r\n\t            if (!firstElementSuit) {\r\n\t                if (mode === undefined) {\r\n\t                    mode = WRAP;\r\n\t                }\r\n\t                if (mode === WRAP) {\r\n\t                    css_1.css(Dom_1.Dom.replace(font, nodeName, _this.jodit.create.inside), cssRules && nodeName.toUpperCase() === defaultTag\r\n\t                        ? cssRules\r\n\t                        : {});\r\n\t                }\r\n\t            }\r\n\t        });\r\n\t        this.restore(selInfo);\r\n\t    };\r\n\t    Select.prototype.splitSelection = function (currentBox) {\r\n\t        if (!this.isCollapsed()) {\r\n\t            return null;\r\n\t        }\r\n\t        var leftRange = this.createRange();\r\n\t        var range = this.range;\r\n\t        leftRange.setStartBefore(currentBox);\r\n\t        var cursorOnTheRight = this.cursorOnTheRight(currentBox);\r\n\t        var cursorOnTheLeft = this.cursorOnTheLeft(currentBox);\r\n\t        var br = null;\r\n\t        if (cursorOnTheRight || cursorOnTheLeft) {\r\n\t            br = this.jodit.create.inside.element('br');\r\n\t            range.insertNode(br);\r\n\t            var clearBR = function (start, getNext) {\r\n\t                var next = getNext(start);\r\n\t                while (next) {\r\n\t                    var nextSib = getNext(next);\r\n\t                    if (next &&\r\n\t                        (Dom_1.Dom.isTag(next, 'br') || Dom_1.Dom.isEmptyTextNode(next))) {\r\n\t                        Dom_1.Dom.safeRemove(next);\r\n\t                    }\r\n\t                    else {\r\n\t                        break;\r\n\t                    }\r\n\t                    next = nextSib;\r\n\t                }\r\n\t            };\r\n\t            clearBR(br, function (n) { return n.nextSibling; });\r\n\t            clearBR(br, function (n) { return n.previousSibling; });\r\n\t            if (cursorOnTheRight) {\r\n\t                leftRange.setEndBefore(br);\r\n\t                range.setEndBefore(br);\r\n\t            }\r\n\t            else {\r\n\t                leftRange.setEndAfter(br);\r\n\t                range.setEndAfter(br);\r\n\t            }\r\n\t        }\r\n\t        else {\r\n\t            leftRange.setEnd(range.startContainer, range.startOffset);\r\n\t        }\r\n\t        var fragment = leftRange.extractContents();\r\n\t        if (currentBox.parentNode) {\r\n\t            try {\r\n\t                currentBox.parentNode.insertBefore(fragment, currentBox);\r\n\t                if (cursorOnTheRight && br && br.parentNode) {\r\n\t                    var range_3 = this.createRange();\r\n\t                    range_3.setStartBefore(br);\r\n\t                    this.selectRange(range_3);\r\n\t                }\r\n\t            }\r\n\t            catch (e) {\r\n\t                console.log(e);\r\n\t            }\r\n\t        }\r\n\t        return currentBox.previousElementSibling;\r\n\t    };*/\r\n\t\t\r\n\t\t\r\n\t\t/*Select.prototype.cursorInTheEdge = function (start, parentBlock) {\r\n\t        var _a;\r\n\t        var end = !start, range = (_a = this.sel) === null || _a === void 0 ? void 0 : _a.getRangeAt(0), current = this.current(false);\r\n\t        if (!range ||\r\n\t            !current ||\r\n\t            !Dom_1.Dom.isOrContains(parentBlock, current, true)) {\r\n\t            return null;\r\n\t        }\r\n\t        var container = start ? range.startContainer : range.endContainer;\r\n\t        var offset = start ? range.startOffset : range.endOffset;\r\n\t        var check = function (elm) {\r\n\t            return elm && !Dom_1.Dom.isTag(elm, 'br') && !Dom_1.Dom.isEmptyTextNode(elm);\r\n\t        };\r\n\t        if (Dom_1.Dom.isText(container)) {\r\n\t            var text = container.nodeValue || '';\r\n\t            if (end && text.replace(constants_1.INVISIBLE_SPACE_REG_EXP_END, '').length > offset) {\r\n\t                return false;\r\n\t            }\r\n\t            var inv = constants_1.INVISIBLE_SPACE_REG_EXP_START.exec(text);\r\n\t            if (start &&\r\n\t                ((inv && inv[0].length < offset) || (!inv && offset > 0))) {\r\n\t                return false;\r\n\t            }\r\n\t        }\r\n\t        else {\r\n\t            var children = Array.from(container.childNodes);\r\n\t            if (end) {\r\n\t                if (children.slice(offset).some(check)) {\r\n\t                    return false;\r\n\t                }\r\n\t            }\r\n\t            else {\r\n\t                if (children.slice(0, offset).some(check)) {\r\n\t                    return false;\r\n\t                }\r\n\t            }\r\n\t        }\r\n\t        var next = start\r\n\t            ? Dom_1.Dom.prev(current, check, parentBlock)\r\n\t            : Dom_1.Dom.next(current, check, parentBlock);\r\n\t        return !next;\r\n\t    };\r\n\t    Select.prototype.cursorOnTheLeft = function (parentBlock) {\r\n\t        return this.cursorInTheEdge(true, parentBlock);\r\n\t    };\r\n\t    Select.prototype.cursorOnTheRight = function (parentBlock) {\r\n\t        return this.cursorInTheEdge(false, parentBlock);\r\n\t    };*/\r\n\t\t\r\n\t\t\r\n\t\tthis.removeMarkers = function()\r\n\t\t{\r\n\t\t\t\r\n\t\t};\r\n\t\t\r\n\t\tthis.__initialize();\r\n\t};\r\n\t\t\r\n\treturn NSSelection;\r\n})();\r\nnsModuleExport(this,\"NSSelection\",NSSelection); var NSExecCommand = (function()\r\n{\r\n\tvar NSExecCommand = function(nsEditor)\r\n\t{\r\n    \tthis.__nsEditor = nsEditor;\r\n\t\tthis.util = nsEditor.util;\r\n\t\tthis.editorUtil = nsEditor.editorUtil;\r\n\t\tthis.selection = nsEditor.__selection;\r\n\t\tthis.doc = null;\r\n\t\tthis.win = null;\r\n\t\tthis.root = null;\r\n\t\tthis.__addingCSS;\r\n\t\t\r\n\t\tvar self = this;\r\n\t\tvar browser = null;\r\n\t\tvar objCommand = {};\r\n\t\tvar objCommandWithExec = {};\r\n\t\t\r\n\t\tthis.initialize = function()\r\n\t\t{\r\n\t\t\tthis.__nsEditor.__listenInternalEvent(\"textAreaInitialized\",function(){\r\n\t\t\t\tself.doc = self.__nsEditor.__getDocument();\r\n\t\t\t\tself.win = self.__nsEditor.__getWindow();\r\n\t\t\t\tself.root = self.__nsEditor.__getTextArea();\r\n\t\t\t});\r\n\t\t\tvar browser = self.util.getBrowser();\r\n\t\t\tobjCommand = {bold:{tag:function(){\r\n\t\t\t\t\treturn browser.isMSIE ? \"strong\" : \"b\";\r\n\t\t\t\t},css: {\"font-weight\": \"bold\"}},\r\n\t\t\t\titalic: {tag:function(){\r\n\t\t\t\t\treturn browser.isMSIE ? \"em\" : \"i\";\r\n\t\t\t\t},css: {\"font-style\": \"italic\"} },\r\n\t\t\t\tunderline: {tag:\"u\",css: {\"text-decoration\": \"underline\"},override: false},\r\n\t\t\t\tstrikethrough: {tag:\"s\",css: {\"text-decoration\": \"line-through\"},override: false},\r\n\t\t\t\tjustifycenter:{css: {\"text-align\": \"center\"}},\r\n\t\t\t\tjustifyleft: {css: {\"text-align\": \"left\"}},\r\n\t\t\t\tjustifyright: {css: {\"text-align\": \"right\"}},\r\n\t\t\t\tjustifyfull: {css: {\"text-align\": \"justify\"}},\r\n\t\t\t\tsubscript: {tag:\"sub\",css: {\"vertical-align\": \"sub\"}},\r\n\t\t\t\tsuperscript: {tag:\"sup\",css: {\"vertical-align\": \"super\"}},\r\n\t\t\t\t\r\n\t\t\t\tundo: {},\r\n\t\t\t\tredo: {},\r\n\t\t\t\toutdent: {css: {\"margin-left\": \"-25\"}},\r\n\t\t\t\tindent: {css: {\"margin-left\": \"+25\"}},\r\n\t\t\t\tfontname: {css:{\"font-family\": \"##args##\"}},\r\n\t\t\t\tfontsize: {\"7\": {css: {\"font-size\": \"xx-large\"}},\r\n\t\t\t\t\t\t   \"6\": {css: {\"font-size\": \"x-large\"}},\r\n\t\t\t\t\t\t   \"5\": {css: {\"font-size\": \"large\"}},\r\n\t\t\t\t\t\t   \"4\": {css: {\"font-size\": \"medium\"}},\r\n\t\t\t\t\t\t   \"3\": {css: {\"font-size\": \"small\"}},\r\n\t\t\t\t\t\t   \"2\": {css: {\"font-size\": \"x-small\"}},\r\n\t\t\t\t\t\t   \"1\": {css: {\"font-size\": \"xx-small\"}}},\r\n\t\t\t\tforecolor: {css:{\"color\": \"##args##\"}},\r\n\t\t\t\tbackcolor: {css:{\"background-color\": \"##args##\"}},\r\n\t\t\t};\r\n\t\t\tobjCommandWithExec = {\r\n\t\t\t\tinsertorderedlist: {exec: this.handleList.bind(this),type: \"ol\"},\r\n\t\t\t\tinsertunorderedlist: {exec: this.handleList.bind(this),type: \"ul\"},\r\n\t\t\t};\r\n\t\t};\r\n\t\t\r\n\t\tthis.execute = function(commandName,showDefaultUI,valueArgument)\r\n\t\t{\r\n\t\t\tvar item = objCommand[commandName.toLowerCase()];\r\n\t\t\tif(item)\r\n\t\t\t{\r\n\t\t\t\tif(!item.css && valueArgument && item[valueArgument])\r\n\t\t\t\t{\r\n\t\t\t\t\titem = item[valueArgument];\r\n\t\t\t\t}\r\n\t\t\t\tif(item.tag || item.css)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar tag = item.tag;\r\n\t\t\t\t\tif(this.util.isFunction(tag))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttag = tag(commandName,item);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif(!this.__nsEditor.__config.enableTagsForProps && item.css)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttag = null;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tvar css = item.css;\r\n\t\t\t\t\tif(item.css && valueArgument)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcss = {}\r\n\t\t\t\t\t\tfor(var prop in item.css)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tvar key = this.util.convertCSSPropToJS(prop);\r\n\t\t\t\t\t\t\tvar value = item.css[prop];\r\n\t\t\t\t\t\t\tif(value == \"##args##\")\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tvalue = valueArgument;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tcss[key] = value;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tthis.applyStyle({tag: tag,css: css});\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse if(objCommandWithExec[commandName.toLowerCase()])\r\n\t\t\t{\r\n\t\t\t\titem = objCommandWithExec[commandName.toLowerCase()];\r\n\t\t\t\tif(item.exec)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn item.exec(item);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\treturn false;\r\n\t\t};\r\n\t\t\r\n\t\tthis.applyStyle = function(option)\r\n\t\t{\r\n\t\t\toption.tag = option.tag || \"span\";\r\n\t\t\t\r\n\t\t\tvar savedSelection = null;\r\n\t\t\tif(this.selection.isCollapsed())\r\n\t\t\t{\r\n\t\t\t\tvar span = this.util.createElement(\"span\",null,\"nsEditorElement nsEditorSelectedWrapper\",this.doc);\r\n\t\t\t\tthis.selection.insertNode(span,false,false);\r\n\t\t\t\tthis.selection.setCursorIn(span);\r\n\t\t\t\tsavedSelection = this.selection.saveSelection(false,true);\r\n\t\t\t\tthis.replaceNode(span,option.tag);\r\n\t\t\t\tthis.editorUtil.removeNode(span);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\t/*var origDomSelection = this.selection.getSelection();\r\n\t\t\t\tif(origDomSelection && (origDomSelection.anchorNode == origDomSelection.focusNode))\r\n\t\t\t\t{\r\n\t\t\t\t\toption.selectedNode = origDomSelection.anchorNode;\r\n\t\t\t\t}*/\r\n\t\t\t\tvar origRange = this.selection.getSelection().getRangeAt(0);\r\n\t\t\t\tsavedSelection = this.selection.saveSelection(false,true);\r\n\t\t\t\tthis.editorUtil.mergeTextNodes(this.root.firstChild);\r\n\t\t\t\tthis.insertTagRestoringSize(this.replaceNode.bind(this),option);\r\n\t\t\t}\r\n\t\t\tthis.selection.restoreSelection(savedSelection);\r\n\t\t};\r\n\t\t\r\n\t\t//Select.prototype.wrapInTag\r\n\t\tthis.insertTagRestoringSize = function(tagOrCallback,option)\r\n\t\t{\r\n\t\t\tvar arrElement = this.root.querySelectorAll(\"*[style*=font-size]\");\r\n\t\t\tvar arrFontsEle = [];\r\n\t\t\tfor(var count = 0;count < arrElement.length;count++)\r\n\t\t\t{\r\n\t\t\t\tvar element = arrElement[count];\r\n\t\t\t\tif(element && element.style && element.style.fontSize)\r\n\t\t\t\t{\r\n\t\t\t\t\tarrFontsEle.push({element: element,size: element.style.fontSize.toString()});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tvar font = this.util.createElement(\"font\",null,\"nsEditorElement nsEditorSelectedWrapper\",this.doc);\r\n\t\t\tfont.setAttribute(\"size\",\"7\");\r\n\t\t\tthis.editorUtil.insertNodeWrappingRange(font);\r\n\t\t\t//this.doc.execCommand('fontsize', false, '7');\r\n\t\t\tfor(var count = 0;count < arrFontsEle.length;count++)\r\n\t\t\t{\r\n\t\t\t\tvar item = arrFontsEle[count];\r\n\t\t\t\tif(item.element && item.element.style && item.size)\r\n\t\t\t\t{\r\n\t\t\t\t\titem.element.style.fontSize = item.size;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tvar result = [];\r\n\t\t\tvar arrFonts = this.root.querySelectorAll('font[size=\"7\"]');\r\n\t\t\tfor(var count = 0;count < arrFonts.length;count++)\r\n\t\t\t{\r\n\t\t\t\tvar font = arrFonts[count];\r\n\t\t\t\ttry\r\n\t\t\t\t{\r\n\t\t\t\t\tif (tagOrCallback && this.util.isFunction(tagOrCallback)) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttagOrCallback(font,option);\r\n\t\t\t\t\t} \r\n\t\t\t\t\telse if(tagOrCallback)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tresult.push(this.util.replaceElement(font,tagOrCallback,null,null,this.doc));\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tfinally\r\n\t\t\t\t{\r\n\t\t\t\t\tif (font.parentNode) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.util.insertElementParentsParent(font);\r\n\t                }\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\t//applyToElement\r\n\t\tthis.replaceNode = function(node,option)\r\n\t\t{\r\n\t\t\tvar self = this;\r\n\t\t\tvar defaultTag = \"span\";\r\n\t\t\tif(this.checkSuitableParent(node,option) || this.checkSuitableChild(node,option) || this.checkClosestWrapper(node,option) || this.unwrapChildren(node,option)) \r\n\t\t\t{\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\tif (this.__addingCSS == null) \r\n\t\t\t{\r\n\t\t\t\t//WRAP\r\n\t\t\t\tthis.__addingCSS = true;\r\n\t\t\t}\r\n\t\t\tif (this.__addingCSS != true) \r\n\t\t\t{\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\tvar wrapper = node;\r\n\t\t\tif (this.editorUtil.isTagBlock(option.tag)) \r\n\t\t\t{\r\n\t\t\t\tvar ulReg = /^(ul|ol|li|td|th|tr|tbody|table)$/i;\r\n\t\t\t\tvar parent = this.util.findParentByCallback(node,function(paramNode){\r\n\t\t\t\t\t\tif (paramNode && self.editorUtil.isBlock(paramNode,self.win)) \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (ulReg.test(option.tag) || !ulReg.test(node.nodeName)) \r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t},this.root);\r\n\t\t\t\tif (parent) \r\n\t\t\t\t{\r\n\t\t\t\t\twrapper = parent;\r\n\t\t\t\t} \r\n\t\t\t\telse \r\n\t\t\t\t{\r\n\t\t\t\t\twrapper = this.wrapUnwrappedText(node);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tvar newWrapper = this.util.replaceElement(wrapper,option.tag,null,null,this.doc);\r\n\t\t\tthis.util.addStyleClass(newWrapper,\"nsEditorSpan\")\r\n\t\t\tif(this.editorUtil.isTagBlock(option.tag)) \r\n\t\t\t{\r\n\t\t\t\tthis.postProcessListElement(newWrapper,option);\r\n\t\t\t}\r\n\t\t\t//&& this.__nsEditor.__config[\"enterElement\"] == option.tag\r\n\t\t\tif(option.css && defaultTag == option.tag) \r\n\t\t\t{\r\n\t\t\t\tthis.util.css(newWrapper,option.css);\r\n\t\t\t}\r\n\t\t\treturn true;\r\n\t\t};\r\n\t\t\r\n\t\tthis.checkSuitableParent = function(node,option) \r\n\t\t{\r\n\t\t\tvar parentNode = node.parentNode;\r\n\t\t\tvar nextNode = !this.util.findNextNode(node,this.isNormalNode.bind(this,option),parentNode);\r\n\t\t\tvar prevNode = !this.util.findPrevNode(node,this.isNormalNode.bind(this,option),parentNode);\r\n\t\t\tvar isSuit = this.isSuitableElement(option,parentNode,false);\r\n\t\t\tvar isBlock = !this.editorUtil.isBlock(parentNode,this.win);\r\n\t\t\tvar isTag = this.editorUtil.isTagBlock(option.tag);\r\n\t\t\t//&& !this.util.findNextNode(node,this.isNormalNode.bind(this,option),parentNode)\r\n\t\t\t//&& !this.util.findPrevNode(node,this.isNormalNode.bind(this,option),parentNode) \r\n\t\t\tif (parentNode  \r\n\t\t\t\t&& this.isSuitableElement(option,parentNode,false) && parentNode != this.root &&\r\n\t\t\t\t(!this.editorUtil.isBlock(parentNode,this.win) || this.editorUtil.isTagBlock(option.tag))) \r\n\t\t\t{\r\n\t\t\t\tthis.toggleStyles(parentNode,option);\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\r\n\t\t\treturn false;\r\n\t\t};\r\n\t\t\r\n\t\tthis.checkSuitableChild = function(node,option)\r\n\t\t{\r\n\t\t\tvar firstChild = node.firstChild;\r\n\t\t\tif (firstChild && !this.util.findNextNode(firstChild,this.isNormalNode.bind(this,option),node) &&\r\n\t\t\t\t!this.util.findPrevNode(firstChild,this.isNormalNode.bind(this,option),node) &&\r\n\t\t\t\tthis.isSuitableElement(option,firstChild,false)) \r\n\t\t\t{\r\n\t\t\t\tthis.toggleStyles(firstChild,option);\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\r\n\t\t\treturn false;\r\n\t\t};\r\n\t\t\r\n\t\tthis.checkClosestWrapper = function(node,option) \r\n\t\t{\r\n\t\t\tvar wrapper = this.editorUtil.getClosestElement(node,this.isSuitableElement.bind(this,option),this.root);\r\n\t\t\tif (wrapper) \r\n\t\t\t{\r\n\t\t\t\tif (this.editorUtil.isTagBlock(option.tag)) \r\n\t\t\t\t{\r\n\t\t\t\t\tthis.toggleStyles(wrapper,option);\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\t\t\t\tvar leftRange = this.selection.createRange();\r\n\t\t\t\tleftRange.setStartBefore(wrapper);\r\n\t\t\t\tleftRange.setEndBefore(node);\r\n\t\t\t\tvar leftFragment = leftRange.extractContents();\r\n\t\t\t\tif ((!leftFragment.textContent || !this.editorUtil.trim(leftFragment.textContent).length) && leftFragment.firstChild) \r\n\t\t\t\t{\r\n\t\t\t\t\tthis.util.insertElementParentsParent(leftFragment.firstChild);\r\n\t\t\t\t}\r\n\t\t\t\tif (wrapper.parentNode) \r\n\t\t\t\t{\r\n\t\t\t\t\twrapper.parentNode.insertBefore(leftFragment,wrapper);\r\n\t\t\t\t}\r\n\t\t\t\tleftRange.setStartAfter(node);\r\n\t\t\t\tleftRange.setEndAfter(wrapper);\r\n\r\n\t\t\t\tvar rightFragment = leftRange.extractContents();\r\n\t\t\t\tif ((!rightFragment.textContent || !this.editorUtil.trim(rightFragment.textContent).length) && rightFragment.firstChild) \r\n\t\t\t\t{\r\n\t\t\t\t\tthis.util.insertElementParentsParent(rightFragment.firstChild);\r\n\t\t\t\t}\r\n\t\t\t\tthis.util.insertAfterElement(wrapper,rightFragment);\r\n\t\t\t\tthis.toggleStyles(wrapper,option);\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t\treturn false;\r\n\t\t};\r\n\t\t\r\n\t\tthis.unwrapChildren = function(node,option)\r\n\t\t{\r\n\t\t\tvar needUnwrap = [];\r\n\t\t\tvar firstElementSuit;\r\n\t\t\tif(node.firstChild) \r\n\t\t\t{\r\n\t\t\t\tvar self = this;\r\n\t\t\t\tthis.util.findNode(node.firstChild,function(paramNode)\r\n\t\t\t\t{\r\n\t\t\t\t\tif(paramNode && self.isSuitableElement(paramNode)) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (firstElementSuit === undefined) \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tfirstElementSuit = true;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tneedUnwrap.push(paramNode);\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\tif(firstElementSuit === undefined) \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tfirstElementSuit = false;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t},node,true);\r\n\t\t\t}\r\n\t\t\tfor(var count = 0;count < needUnwrap.length;count++)\r\n\t\t\t{\r\n\t\t\t\tvar paramNode = needUnwrap[count];\r\n\t\t\t\tthis.util.insertElementParentsParent(paramNode);\r\n\t\t\t}\r\n\t\t\treturn firstElementSuit;\r\n\t\t}\r\n\t\t\r\n\t\tthis.toggleStyles = function(node,option) \r\n\t\t{\r\n\t\t\tvar css = option.css;\r\n\t\t\tvar element = option.tag || \"span\";\r\n\t\t\tvar defaultTag = \"span\";\r\n\t\t\tvar elementIsDefault = (defaultTag == node.nodeName.toLowerCase());\r\n\t\t\tif (css && elementIsDefault)\r\n\t\t\t{\r\n\t\t\t\tfor(var key in css)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar nodeValue = this.util.getStyleValue(node,key,false,true,this.win);\r\n\t\t\t\t\tvar valueToBeSet = this.normalizeCssValue(key,css[key]);\r\n\t\t\t\t\tif(nodeValue && /color/i.test(key) && /^rgb/i.test(nodeValue.toString())) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tnodeValue = this.util.colorToHex(nodeValue.toString()) || nodeValue;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//console.log(key + \",\" + nodeValue + \",\" + valueToBeSet);\r\n\t\t\t\t\tif (this.__addingCSS == false || (nodeValue == valueToBeSet)) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.util.css(node,key,'');\r\n\t\t\t\t\t\tif(this.__addingCSS == undefined) \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t//UNWRAP\r\n\t\t\t\t\t\t\tthis.__addingCSS = false;\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\tthis.util.css(node, key, css[key]);\r\n\t\t\t\t\t\tif(this.__addingCSS == undefined) \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t//WRAP\r\n\t\t\t\t\t\t\tthis.__addingCSS = true;\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 isBlock = this.editorUtil.isBlock(node,this.root);\r\n\t\t\tvar isSuitableInline = !isBlock && (!node.hasAttribute('style') || node.nodeName.toLowerCase() != defaultTag);\r\n\t\t\tvar isSuitableBlock = !isSuitableInline && isBlock && node.nodeName.toLowerCase() == element;\r\n\t\t\tif (isSuitableInline || isSuitableBlock) \r\n\t\t\t{\r\n\t\t\t\t// toggle `<strong>test</strong>` toWYSIWYG `test`, and\r\n\t\t\t\t// `<span style=\"\">test</span>` toWYSIWYG `test`\r\n\t\t\t\tthis.util.insertElementParentsParent(node);\r\n\t\t\t\tif(this.__addingCSS == undefined) \r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__addingCSS = false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.isSuitableElement = function(option,node,strict)\r\n\t\t{\r\n\t\t\tif(node) \r\n\t\t\t{\r\n\t\t\t\tstrict = this.util.isUndefinedOrNull(strict) ? true : Boolean.parse(strict);\r\n\t\t\t\tvar element = option.tag || this.__nsEditor.__config[\"enterElement\"];\r\n\t\t\t\tvar elementIsDefault = (this.__nsEditor.__config[\"enterElement\"] == option.tag);\r\n\t\t\t\tvar elmHasSameStyle = this.isStyleValueExists(node,option.css);\r\n\t\t\t\tvar elmIsSame = (node.nodeName.toLowerCase() == element);\r\n\r\n\t\t\t\treturn (((!elementIsDefault || !strict) && elmIsSame) || (elmHasSameStyle && this.isNormalNode(option,node)));\r\n\t\t\t}\r\n\t\t\treturn false;\r\n\t\t};\r\n\t\t\r\n\t\tthis.isStyleValueExists = function(node,objStyle)\r\n\t\t{\r\n\t\t\tvar matches = false;\r\n\t\t\tif(node && this.util.isElement(node) && !this.util.hasStyleClass(node,\"nsEditorSelectedWrapper\")) \r\n\t\t\t{\r\n\t\t\t\tmatches = true;\r\n\t\t\t\tvar style = this.win.getComputedStyle(node);\r\n\t\t\t\tfor(var styleProp in objStyle)\r\n\t\t\t\t{\r\n\t\t\t\t\tif(style[styleProp] != objStyle[styleProp])\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tmatches = false;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\treturn matches;\r\n\t\t};\r\n\r\n\t\tthis.isNormalNode = function(option,node) \r\n\t\t{\r\n\t\t\treturn (node != null && !this.editorUtil.isEmptyTextNode(node) && !this.selection.isSelectionWrapper(node));\r\n\t\t};\r\n\t\t\r\n\t\tthis.normalizeCssValue = function(key,value)\r\n\t\t{\r\n\t\t\tswitch (this.util.toKebabCase(key)) \r\n\t\t\t{\r\n\t\t\t\tcase 'font-weight':\r\n\t\t\t\t\tswitch (value.toString().toLowerCase()) {\r\n\t\t\t\t\t\tcase '700':\r\n\t\t\t\t\t\tcase 'bold':\r\n\t\t\t\t\t\t\treturn \"bold\";\r\n\r\n\t\t\t\t\t\tcase '400':\r\n\t\t\t\t\t\tcase 'normal':\r\n\t\t\t\t\t\t\treturn \"normal\";\r\n\r\n\t\t\t\t\t\tcase '900':\r\n\t\t\t\t\t\tcase 'heavy':\r\n\t\t\t\t\t\t\treturn \"heavy\";\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\treturn this.util.isNumeric(value) ? Number(value) : value;\r\n\t\t\t}\r\n\r\n\t\t\tif (/color/i.test(key) && /^rgb/i.test(value.toString())) \r\n\t\t\t{\r\n\t\t\t\treturn this.util.colorToHex(value.toString()) || value;\r\n\t\t\t}\r\n\t\t\treturn value;\r\n\t\t};\r\n\r\n\t\t\r\n\t\tthis.postProcessListElement = function(wrapper,option) \r\n\t\t{\r\n\t        if (/^(OL|UL)$/i.test(option.tag) && wrapper.tagName.toLowerCase() == option.tag.toLowerCase()) \r\n\t        {\r\n\t            var li = this.util.replaceElement(wrapper,\"li\",null,null,this.doc);\r\n\t            var ul = this.editorUtil.wrapNode(li,option.tag);\r\n\t            if(ul) \r\n\t            {\r\n\t                wrapper = ul;\r\n\t            }\r\n\t        }\r\n\t    };\r\n\t    \r\n\t    /********* List related functions *******************/\r\n\t\t\r\n\t\tthis.handleList = function(item)\r\n\t\t{\r\n\t\t\tvar selection = this.selection.getSelection();\r\n\t\t\tvar anchorNode = selection.anchorNode;\r\n\t\t\tif(anchorNode) \r\n\t\t\t{\r\n\t\t\t\tvar container = anchorNode.nodeType != Node.TEXT_NODE && anchorNode.nodeType != Node.COMMENT_NODE ? anchorNode : anchorNode.parentElement;\r\n\t\t\t\tvar range = selection.getRangeAt(0);\r\n\t\t\t\t//selected all list\r\n\t\t\t\tif(range.commonAncestorContainer && range.commonAncestorContainer.nodeName.toLowerCase() == item.type) \r\n\t\t\t\t{\r\n\t\t\t\t\tthis.removeList(range);\r\n\t\t\t\t}\r\n\t\t\t\t//selected li\r\n\t\t\t\telse if (container.nodeName.toLowerCase() == \"li\") \r\n\t\t\t\t{\r\n\t\t\t\t\tthis.removeListItem(container,range,selection,item.type);\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.createList(container,range,selection,item.type);\r\n\t\t\t\t}\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.createList = function(container,range,selection,type)\r\n\t\t{\r\n\t\t\tvar fragment = range.extractContents();\r\n\t\t\tvar list = this.doc.createElement(type);\r\n\t\t\tlist.setAttribute(\"class\",\"nsExecCommandList\");\r\n\t\t\tvar li = this.doc.createElement(\"li\");\r\n\t\t\tli.style.cssText = container.style.cssText;\r\n\t\t\tli.appendChild(fragment);\r\n\t\t\tlist.appendChild(li);\r\n\t\t\trange.insertNode(list);\r\n\t\t\tselection.selectAllChildren(list);\r\n\t\t};\r\n\t\t\r\n\t\tthis.removeList = function(range)\r\n\t\t{\r\n\t\t\tvar list = range.commonAncestorContainer;\r\n\t\t\tif(list.childNodes && list.childNodes.length) \r\n\t\t\t{\r\n\t\t\t\tvar arrChildren = list.childNodes;\r\n\t\t\t\tfor(var count = 0;count < arrChildren.length;count++)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar child = arrChildren[count];\r\n\t\t\t\t\tif(child.childNodes && child.childNodes.length > 1 && \r\n\t\t\t\t\t   child.firstChild.nodeType != Node.TEXT_NODE &&\r\n\t\t\t\t\t   child.firstChild.nodeType != Node.COMMENT_NODE)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar span = this.doc.createElement(\"span\");\r\n\t\t\t\t\t\tspan.setAttribute(\"class\",\"nsExecListCommand\");\r\n\t\t\t\t\t\tfor(var childCount = 0;childCount < child.childNodes.length;childCount++)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tspan.appendChild(child.childNodes[childCount]);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t        list.parentElement.insertBefore(span,list);\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        var text = this.doc.createTextNode(child.textContent);\r\n\t\t\t\t        list.parentElement.insertBefore(text,list);\r\n\t\t\t\t    }\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tlist.parentElement.removeChild(list);\r\n\t\t};\r\n\t\t\r\n\t\tthis.removeListItem = function(container,range,selection,type) \r\n\t\t{\r\n\t\t\tthis.movePreviousListItem(container,type);\r\n\t\t\tthis.moveNextListItem(container,type);\r\n\t\t\tvar span = this.doc.createElement(\"span\");\r\n\t\t\tspan.setAttribute(\"class\",\"nsExecListCommand\");\r\n\t\t\tspan.style.cssText = container.style.cssText;\r\n\t\t\tvar fragment = range.extractContents();\r\n\t\t\tspan.appendChild(fragment);\r\n\t\t\tvar dest = container.parentElement.nextElementSibling ? container.parentElement.nextElementSibling : container.parentElement.parentElement.lastChild;\r\n\t\t\tcontainer.parentElement.parentElement.insertBefore(span,dest);\r\n\t\t\tselection.selectAllChildren(container);\r\n\t\t\tvar list = container.parentElement;\r\n\t\t\tlist.removeChild(container);\r\n\t\t\tif(!list.childNodes || !list.childNodes.length) \r\n\t\t\t{\r\n\t\t\t    list.parentElement.removeChild(list);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.movePreviousListItem = function(container,type) \r\n\t\t{\r\n\t\t\tif (container.previousElementSibling && container.previousElementSibling.nodeName.toLowerCase() == \"li\") \r\n\t\t\t{\r\n\t\t\t    var list = this.moveListItem(container.previousElementSibling,true,type);\r\n\t\t\t    if (list) \r\n\t\t\t    {\r\n\t\t\t    \tcontainer.parentElement.parentElement.insertBefore(list,container.parentElement);\r\n\t\t\t    }\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.moveNextListItem = function(container,type) \r\n\t\t{\r\n\t\t\tif (container.nextElementSibling && container.nextElementSibling.nodeName.toLowerCase() == \"li\") \r\n\t\t\t{\r\n\t\t\t    var list = this.moveListItem(container.nextElementSibling,false,type);\r\n\t\t\t    if(list) \r\n\t\t\t    {\r\n\t\t\t    \tif(container.parentElement.nextSibling)\r\n\t\t\t    \t{\r\n\t\t\t    \t\tcontainer.parentElement.parentElement.insertBefore(list,container.parentElement.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\tcontainer.parentElement.parentElement.appendChild(list);\r\n\t\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.moveListItem = function(sibling,isPrevious,type) \r\n\t\t{\r\n\t\t\tif(!sibling || sibling.nodeName.toLowerCase() != \"li\") \r\n\t\t\t{\r\n\t\t\t    return null;\r\n\t\t\t}\r\n\t\t\tvar children = [];\r\n\t\t\twhile (sibling && sibling.nodeName.toLowerCase() == \"li\") \r\n\t\t\t{\r\n\t\t\t    children.push(sibling);\r\n\t\t\t    sibling = isPrevious ? sibling.previousElementSibling : sibling.nextElementSibling;\r\n\t\t\t}\r\n\t\t\tif (!children || children.length <= 0) \r\n\t\t\t{\r\n\t\t\t    return null;\r\n\t\t\t}\r\n\t\t\tvar list = this.doc.createElement(type);\r\n\t\t\tlist.setAttribute(\"class\",\"nsExecCommandList\");\r\n\t\t\tif(isPrevious) \r\n\t\t\t{\r\n\t\t\t\tchildren.reverse();\r\n\t\t\t}\r\n\t\t\tfor(var count = 0;count < children.length;count++)\r\n\t\t\t{\r\n\t\t\t\tlist.appendChild(children[count]);\r\n\t\t\t}\r\n\t\t\treturn list;\r\n\t\t};\r\n\t\t\r\n\t\t/********* end of List related functions *******************/\r\n\t\t\r\n\t    this.initialize();\r\n\t\t\r\n    };\r\n\t\r\n\treturn NSExecCommand;\r\n})();\r\nnsModuleExport(this,\"NSExecCommand\",NSExecCommand); var NSStack = (function()\r\n{\r\n\tvar NSStack = function(nsEditor)\r\n\t{\r\n\t\tthis.__nsEditor = nsEditor;\r\n\t\tthis.util = nsEditor.util;\r\n\t\tthis.editorUtil = nsEditor.editorUtil;\r\n\t\t\r\n\t\tthis.arrCommands = [];\r\n        this.index = -1;\r\n\t\t\r\n\t\tthis.__initialize = function()\r\n\t\t{\r\n\t\t\t\r\n\t\t};\r\n\t\t\r\n\t\tthis.clearRedo = function() \r\n\t\t{\r\n\t        this.arrCommands.length = this.index + 1;\r\n\t    };\r\n\t    \r\n\t    this.clear = function() \r\n\t    {\r\n\t        this.arrCommands.length = 0;\r\n\t        this.index = -1;\r\n\t    };\r\n\t    \r\n\t    this.push = function(command) \r\n\t    {\r\n\t        this.clearRedo();\r\n\t        this.arrCommands.push(command);\r\n\t        this.index += 1;\r\n\t    };\r\n\t    \r\n\t    this.undo = function() \r\n\t    {\r\n\t        if(this.canUndo()) \r\n\t        {\r\n\t            if (this.arrCommands[this.index]) \r\n\t            {\r\n\t                this.arrCommands[this.index].undo();\r\n\t            }\r\n\t            this.index -= 1;\r\n\t            return true;\r\n\t        }\r\n\t        return false;\r\n\t    };\r\n\t    \r\n\t    this.redo = function() \r\n\t    {\r\n\t        if (this.canRedo()) \r\n\t        {\r\n\t            this.index += 1;\r\n\t            if (this.arrCommands[this.index]) \r\n\t            {\r\n\t                this.arrCommands[this.index].redo();\r\n\t            }\r\n\t            return true;\r\n\t        }\r\n\t        return false;\r\n\t    };\r\n\t    \r\n\t    this.canUndo = function () \r\n\t    {\r\n\t        return this.index >= 0;\r\n\t    };\r\n\t    \r\n\t    this.canRedo = function () \r\n\t    {\r\n\t        return this.index < this.arrCommands.length - 1;\r\n\t    };\r\n\t\t\r\n\t\tthis.__initialize();\r\n\t};\r\n\t\t\r\n\treturn NSStack;\r\n})();\r\nnsModuleExport(this,\"NSStack\",NSStack); var NSEditorModal = (function()\r\n{\r\n\tvar NSEditorModal = function(nsEditor,nsParentPluggin,setting)\r\n\t{\r\n\t\tthis.__nsEditor = nsEditor;\r\n\t\tthis.__nsParentPluggin = nsParentPluggin;\r\n\t\tthis.__setting = setting;\r\n\t\tthis.util = nsEditor.util;\r\n\t\tthis.editorUtil = nsEditor.editorUtil;\r\n\t\t\r\n\t\tthis.__divModalMask = null;\r\n\t\tthis.__divDragMask = null;\r\n\t\tthis.__id = null;\r\n\t\tthis.__compOuterContainer = null;\r\n\t\tthis.__originalValue = null;\r\n\t\tthis.__objDrag = null;\r\n\t\t\r\n\t\tthis.__initialize = function()\r\n\t\t{\r\n\t\t\tthis.__setSetting();\r\n\t\t\tthis.__componentsInitialized();\r\n\t\t};\r\n\t\t\r\n\t\tthis.__setSetting = function()\r\n\t\t{\r\n\t\t\tif(!this.__setting)\r\n\t\t\t{\r\n\t\t\t\tthrow this.util.throwNSError(\"NSEditorModal\",\"Setting for Pluggin \" + this.__nsParentPluggin.name + \" is not defined\");\r\n\t\t\t}\r\n\t\t\tvar config = this.__setting;\r\n\t\t\tif(!config.contentCallback)\r\n\t\t\t{\r\n\t\t\t\tthrow this.util.throwNSError(\"NSEditorModal\",\"ContentCallback in setting for Pluggin \" + this.__nsParentPluggin.name + \" is not defined\");\r\n\t\t\t}\r\n\t\t\tthis.__config = {\r\n\t\t\t\t\t\t\t\tcontainer: config[\"container\"] || this.__nsEditor.__getFixedComp(),\r\n\t\t\t\t\t\t\t\ttitle: config[\"title\"] || \"\",\r\n\t\t\t\t\t\t\t\tenableDraggable: this.util.isUndefinedOrNull(config[\"enableDraggable\"]) ? true : Boolean.parse(config[\"enableDraggable\"]),\r\n\t\t\t\t\t\t\t\tenableReset: this.util.isUndefinedOrNull(config[\"enableReset\"]) ? true : Boolean.parse(config[\"enableReset\"]),\r\n\t\t\t\t\t\t\t\tshowMask: this.util.isUndefinedOrNull(config[\"showMask\"]) ? true : Boolean.parse(config[\"showMask\"]),\r\n\t\t\t\t\t\t\t\tcontentCSSClass: config[\"contentCSSClass\"] || \"\",\r\n\t\t\t\t\t\t\t\tcontentCallback: this.util.getFunction(config[\"contentCallback\"]),\r\n\t\t\t\t\t\t\t\tfooterCallback: this.util.getFunction(config[\"footerCallback\"]),\r\n\t\t\t\t\t\t\t\tcloseCallback: this.util.getFunction(config[\"closeCallback\"]),\r\n\t\t\t\t\t\t\t\tisFullScreen: Boolean.parse(config[\"isFullScreen\"])\r\n\t\t\t\t\t\t    };\r\n\t\t\t\r\n\t\t};\r\n\t\t\r\n\t\tthis.__componentsInitialized = function()\r\n\t\t{\r\n\t\t\tthis.__createComponents();\r\n\t\t\tthis.__nsEditor.__listenInternalEvent(\"resized change changePlace readonly\",this.hide.bind(this));\r\n\t\t\tthis.__nsEditor.__listenInternalEvent(\"destroy\",this.destroy.bind(this));\r\n\t\t};\r\n\t\t\r\n\t\tthis.__createComponents = function()\r\n\t\t{\r\n\t\t\tthis.__id = this.__nsEditor.getID() + this.__nsParentPluggin.name + \"EditorModal\";\r\n\t\t\tif(!this.__divModalMask)\r\n\t\t\t{\r\n\t\t\t\tif(this.__config.container.querySelector(\".nsEditorModalMask\"))\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__divModalMask = this.__config.container.querySelector(\".nsEditorModalMask\");\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.__divModalMask = this.util.createDiv(this.__id + \"ModalMask\",\"nsEditorModalMask\");\r\n\t\t\t\t\tthis.__config.container.appendChild(this.__divModalMask);\r\n\t\t\t\t\tthis.util.addEvent(this.__divModalMask,\"click\",this.close.bind(this));\r\n\t\t\t\t\tthis.util.addEvent(this.__divModalMask,\"mouseDown\",this.__maskMouseDownHandler.bind(this));\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif(!this.__divDragMask)\r\n\t\t\t{\r\n\t\t\t\tif(this.__config.container.querySelector(\".nsEditorModalDragMask\"))\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__divDragMask = this.__config.container.querySelector(\".nsEditorModalDragMask\");\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.__divDragMask = this.util.createDiv(this.__id + \"DragMask\",\"nsEditorModalDragMask\");\r\n\t\t\t\t\tthis.__config.container.appendChild(this.__divDragMask);\r\n\t\t\t\t\tthis.util.addEvent(this.__divDragMask,\"mouseDown\",this.__maskMouseDownHandler.bind(this));\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tthis.destroy();\r\n\t\t\tthis.__compOuterContainer = this.__getContainer();\r\n\t\t\tthis.__config.container.appendChild(this.__compOuterContainer);\r\n\t\t\tthis.__hide();\r\n\t\t};\r\n\t\t\r\n\t\tthis.toggle = function()\r\n\t\t{\r\n\t\t\tthis.isHidden() ? this.show() : this.hide();\r\n\t\t};\r\n\t\t\r\n\t\tthis.show = function() \r\n\t\t{\r\n\t\t\tif (this.__config.enableReset) \r\n\t\t    {\r\n\t\t\t\tthis.reset();\r\n\t\t    }\r\n\t\t    this.showAtCenter();\r\n\t\t};\r\n\t\t\r\n\t\tthis.hide = function()\r\n\t\t{\r\n\t\t\tif (!this.isHidden()) \r\n\t\t\t{\r\n\t\t\t\tthis.__hide();\r\n\t\t\t\tthis.__nsEditor.__dispatchInternalEvent(\"modalhide\",{modal:this});\r\n\t\t    }\r\n\t\t};\r\n\t\t\r\n\t\tthis.showAtCenter = function()\r\n\t\t{\r\n\t\t\tvar doc = this.__nsEditor.__dom.doc;\r\n\t\t\tvar html = doc.documentElement || doc.body;\r\n\t\t\tvar body = doc.body;\r\n\t\t\tvar htmlRect = html.getBoundingClientRect();\r\n\t\t\tif (this.__config.isFullScreen) \r\n\t\t\t{\r\n\t\t\t\tvar modalContent = this.__compOuterContainer.querySelector(\".nsEditorModalContentContainer\");\r\n\t\t        this.__compOuterContainer.style.display = \"block\";\r\n\r\n\t\t        var rectContainer = this.__compOuterContainer.getBoundingClientRect();\r\n\t\t        var rectContent = modalContent.getBoundingClientRect();\r\n\t\t        this.__compOuterContainer.style.left = \"-100000px\";\r\n\r\n\t\t        var contentWidth = htmlRect.width - rectContainer.width + rectContent.width;\r\n\t\t        var contentHeight = htmlRect.height - rectContainer.height + rectContent.height;\r\n\t\t        this.util.css(modalContent,{width: contentWidth,height: contentHeight});\r\n\t\t        this.util.css(this.__compOuterContainer,{width: htmlRect.width,height: htmlRect.height,left: 0});\r\n\t\t        \r\n\t\t        this.__originalValue = {\r\n\t\t          html: {\r\n\t\t            overflowX: html.style.overflowX,\r\n\t\t            overflowY: html.style.overflowY\r\n\t\t          },\r\n\t\t          body: {\r\n\t\t            overflowX: body.style.overflowX,\r\n\t\t            overflowY: body.style.overflowY\r\n\t\t          }\r\n\t\t        };\r\n\t\t        var styleOverflow = {overflowX: \"hidden\",overflowY: \"hidden\"};\r\n\t\t        this.util.css(doc.documentElement,styleOverflow);\r\n\t\t        this.util.css(body,styleOverflow);\r\n\t\t    } \r\n\t\t\telse \r\n\t\t\t{\r\n\t\t\t\t this.__compOuterContainer.style.display = \"\";\r\n\t\t\t     var popSize = this.__fitSize();\r\n\t\t\t     var titleBar = this.__compOuterContainer.querySelector(\".nsEditorModalTitlebar\");\r\n\t\t\t     var titleHeight = titleBar.offsetHeight | 0;\r\n\t\t\t     var left = htmlRect.width / 2 - popSize.width / 2;\r\n\t\t\t     var top = htmlRect.height / 2 - (popSize.height - titleHeight) / 2 - titleHeight;\r\n\t\t\t     this.__safeSetOffset({left: Math.max(left | 0, 0),top: Math.max(top | 0, 0)});\r\n\t\t\t     this.util.addStyleClass(this.__compOuterContainer,\"nsEditorModalCentered\");\r\n\t\t    }\r\n\t\t\tthis.__show();\r\n\t\t};\r\n\t\t\r\n\t\tthis.reset = function() \r\n\t\t{\r\n\t\t\tif(!this.isDestroyed())\r\n\t\t\t{\r\n\t\t\t\tvar divContent = this.__compOuterContainer.querySelector(\".nsEditorModalContent\");\r\n\t\t\t\tvar htmlContent = this.__config.contentCallback(this,this.__nsParentPluggin);\r\n\t\t\t\tdivContent.innerHTML = htmlContent;\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.close = function() \r\n\t\t{\r\n\t\t\tif (this.__config.isFullScreen && this.__originalValue) \r\n\t\t\t{\r\n\t\t\t\tvar doc = this.__nsEditor.__dom.doc;\r\n\t\t\t\tvar body = doc.body;\r\n\t\t\t\tvar docElement = doc.documentElement;\r\n\t\t\t\tthis.util.css(docElement,this.__originalValue.html);\r\n\t\t        this.util.css(body,this.__originalValue.body);\r\n\t\t        this.__originalValue = null;\r\n\t\t    }\r\n\t\t\tthis.hide();\r\n\t\t};\r\n\t\t\r\n\t\tthis.isHidden = function()\r\n\t\t{\r\n\t\t\tif(!this.isDestroyed())\r\n\t\t\t{\r\n\t\t\t\treturn (this.__compOuterContainer.style.display == \"none\")\r\n\t\t\t}\r\n\t\t\treturn true;\r\n\t\t};\r\n\t\t\r\n\t\tthis.isDestroyed = function()\r\n\t\t{\r\n\t\t\tif(this.__compOuterContainer && this.__compOuterContainer.parentElement)\r\n\t\t\t{\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\treturn true;\r\n\t\t};\r\n\t\t\r\n\t\tthis.destroy = function()\r\n\t\t{\r\n\t\t\tif(this.__compOuterContainer && this.__compOuterContainer.parentElement)\r\n\t\t\t{\r\n\t\t\t\tthis.__compOuterContainer.parentElement.removeChild(this.__compOuterContainer);\r\n\t\t\t\tthis.__compOuterContainer = null;\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__show = function()\r\n\t\t{\r\n\t\t\t//if (this.isHidden()) \r\n\t\t\t//{\r\n\t\t\t\tvar container = this.__compOuterContainer;\r\n\t\t\t\tcontainer.style.display = \"\";\r\n\t\t\t\tvar maxZIndex = this.util.getMaxZIndex();\r\n\t\t\t\tvar zIndex = maxZIndex + 10;\r\n\t\t\t\tcontainer.style.zIndex = zIndex;\r\n\t\t\t\tthis.__nsEditor.__getFixedComp().style.zIndex = zIndex - 4;\r\n\t\t\t\tthis.__showModalMask(zIndex - 2);\r\n\t\t    //}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__hide = function()\r\n\t\t{\r\n\t\t\tvar container = this.__compOuterContainer;\r\n\t\t\tvar style = {display: \"none\",zIndex: \"\",width: \"\",height: \"\"};\r\n\t        this.util.css(container,style);\r\n\t        this.__hideModalMask();\r\n\t\t};\r\n\t\t\r\n\t\tthis.__fitSize = function()\r\n\t\t{\r\n\t\t\tvar modalBody = this.__compOuterContainer.querySelector(\".nsEditorModalBody\");\r\n\t\t\tvar modalContent = this.__compOuterContainer.querySelector(\".nsEditorModalContentContainer\");\r\n\t\t\t//var rectModalContent = modalContent.getBoundingClientRect();\r\n\t\t\tvar rectModalBody = modalBody.getBoundingClientRect();\r\n\t\t\tmodalBody.style.width = rectModalBody.width + \"px\";\r\n\t\t\tmodalBody.style.height = rectModalBody.height + \"px\";\r\n\t\t\treturn rectModalBody;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__safeSetOffset = function(offset) \r\n\t\t{\r\n\t\t\tvar doc = this.__nsEditor.__dom.doc;\r\n\t\t\tvar html = doc.documentElement || doc.body;\r\n\t\t\tvar htmlRect = html.getBoundingClientRect();\r\n\t\t    var rect = this.__compOuterContainer.getBoundingClientRect();\r\n\t\t    var left = offset.left;\r\n\t\t    if (left + rect.width > htmlRect.right) \r\n\t\t    {\r\n\t\t        left = htmlRect.right - rect.width;\r\n\t\t    }\r\n\t\t    var top = offset.top;\r\n\t\t    if (top + rect.height > htmlRect.bottom) \r\n\t\t    {\r\n\t\t        top = htmlRect.bottom - rect.height;\r\n\t\t    }\r\n\t\t    this.util.css(this.__compOuterContainer,{left: Math.max(left, 0),top: Math.max(top, 0)});\r\n\t\t};\r\n\t\t\r\n\t\tthis.__showModalMask = function(zIndex)\r\n\t\t{\r\n\t\t\tif(this.__config.showMask)\r\n\t\t\t{\r\n\t\t\t\tthis.__setModalMask();\r\n\t\t\t\tvar style = {display: \"\",zIndex: zIndex};\r\n\t\t        this.util.css(this.__divModalMask,style);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__hideModalMask = function()\r\n\t\t{\r\n\t\t\tvar style = {display: \"none\",zIndex: \"\",width:\"\",height:\"\"};\r\n\t        this.util.css(this.__divModalMask,style);\r\n\t\t};\r\n\t\t\r\n\t\tthis.__setModalMask = function()\r\n\t\t{\r\n\t\t\tvar doc = this.__nsEditor.__dom.doc;\r\n\t\t\tvar html = doc.documentElement || doc.body;\r\n\t\t\tvar htmlRect = html.getBoundingClientRect();\r\n\t\t\tvar style = {width: htmlRect.width,height: htmlRect.height};\r\n\t        this.util.css(this.__divModalMask,style);\r\n\t\t};\r\n\t\t\r\n\t\tthis.__maskMouseDownHandler = function(event)\r\n\t\t{\r\n\t\t\tevent = this.util.getEvent(event);\r\n\t\t\tevent.preventDefault();\r\n\t\t};\r\n\t\t\r\n\t\tthis.__titleBarMouseDownHandler = function(event)\r\n\t\t{\r\n\t\t\tif(this.__config.enableDraggable)\r\n\t\t\t{\r\n\t\t\t\tevent = this.util.getEvent(event);\r\n\t\t\t\tvar win = this.__nsEditor.__dom.window;\r\n\t\t\t\tvar doc = this.__nsEditor.__dom.doc;\r\n\t\t\t\tvar html = doc.documentElement || doc.body;\r\n\t\t\t\tvar htmlRect = html.getBoundingClientRect();\r\n\t\t\t\tthis.__objDrag = {dragging:true,startX: event.clientX,startY: event.clientY,dragging:this.__dragging.bind(this),dragEnd:this.__dragEnd.bind(this)};\r\n\t\t\t\tthis.util.addEvent(doc,\"mousemove\",this.__objDrag.dragging);\r\n\t\t\t\tthis.util.addEvent(doc,\"mouseup\",this.__objDrag.dragEnd);\r\n\t\t\t\tthis.util.addEvent(win,\"mouseup\",this.__objDrag.dragEnd);\r\n\t\t\t\tevent.preventDefault();\r\n\t\t\t\tthis.__dragStart(event);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__dragStart = function(event)\r\n\t\t{\r\n\t\t\tthis.__objDrag.rect = this.__compOuterContainer.getBoundingClientRect();\r\n\t\t\tvar contentMask = this.__compOuterContainer.querySelector(\".nsEditorModalContentMask\");\r\n\t\t\tcontentMask.style.visibility = \"visible\";\r\n\t\t\tvar zIndex = this.__compOuterContainer.style.zIndex;\r\n\t\t\tthis.__showModalMask(zIndex - 1);\r\n\t\t};\r\n\t\t\r\n\t\tthis.__dragging = function(event)\r\n\t\t{\r\n\t\t\tif(this.__objDrag && this.__objDrag.dragging)\r\n\t\t\t{\r\n\t\t\t\tevent = this.util.getEvent(event);\r\n\t\t\t\tvar x = event.clientX - this.__objDrag.startX;\r\n\t\t        var y = event.clientY - this.__objDrag.startY;\r\n\t\t        var offset = {};\r\n\t\t        offset.left = this.__objDrag.rect.left + x;\r\n\t\t        offset.top = this.__objDrag.rect.top + y;\r\n\t            this.__safeSetOffset(offset);\r\n\t\t        event.stopPropagation();\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__dragEnd = function(event)\r\n\t\t{\r\n\t\t\tif(this.__objDrag)\r\n\t\t\t{\r\n\t\t\t\tvar win = this.__nsEditor.__dom.window;\r\n\t\t\t\tvar doc = this.__nsEditor.__dom.doc;\r\n\t\t\t\tthis.util.removeEvent(doc,\"mousemove\",this.__objDrag.dragging);\r\n\t\t\t\tthis.util.removeEvent(doc,\"mouseup\",this.__objDrag.dragEnd);\r\n\t\t\t\tthis.util.removeEvent(win,\"mouseup\",this.__objDrag.dragEnd);\r\n\t\t\t\tif(this.__objDrag.dragging)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar contentMask = this.__compOuterContainer.querySelector(\".nsEditorModalContentMask\");\r\n\t\t\t\t\tcontentMask.style.visibility = \"hidden\";\r\n\t\t\t\t\tthis.util.removeStyleClass(this.__compOuterContainer,\"nsEditorModalCentered\");\r\n\t\t\t\t\t//this.__hideModalMask();\r\n\t\t\t\t}\r\n\t\t\t\tthis.__objDrag = null;\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__getContainer = function()\r\n\t\t{\r\n\t\t\tvar htmlContent = this.__config.contentCallback(this,this.__nsParentPluggin);\r\n\t\t\tvar htmlFooter = this.__config.footerCallback ? this.__config.footerCallback(this,this.__nsParentPluggin) : \"\";\r\n\t\t\tvar modalContainerClass = this.__config.isFullScreen ? \"nsEditorModalContainerFullScreen\" : \"nsEditorModal nsEditorFor##name##\";\r\n\t\t\tvar html = \"<div id=\\\"##id##ModalOuterContainer\\\" class=\\\"nsEditorModal nsEditorFor##name##\\\">\\r\\n\" + \r\n\"\t\t\t\t\t\t\t<div id=\\\"##id##ModalContainer\\\" class=\\\"\" + modalContainerClass + \" nsEditorModalContainer\\\">\\r\\n\" + \r\n\"\t\t\t\t\t\t\t\t<div id=\\\"##id##ModalBody\\\" class=\\\"nsEditorModalBody\\\">\\r\\n\" + \r\n\"\t\t\t\t\t\t\t\t\t<div class=\\\"nsEditorModalShadow\\\"></div>\\r\\n\" + \r\n\"\t\t\t\t\t\t\t\t\t<div id=\\\"##id##ModalTitlebar\\\" class=\\\"nsEditorModalTitlebar\\\">\\r\\n\" + \r\n\"\t\t\t\t\t\t\t\t\t\t<div class=\\\"nsEditorModalDragHandle\\\">\\r\\n\" + \r\n\"\t\t\t\t\t\t\t\t\t\t\t<span class=\\\"nsEditorModalCaption\\\">\\r\\n\" + \r\n\"\t\t\t\t\t\t\t\t\t\t\t\t\" + this.__config.title + \" \\r\\n\" + \r\n\"\t\t\t\t\t\t\t\t\t\t\t</span>\\r\\n\" + \r\n\"\t\t\t\t\t\t\t\t\t\t</div>\\r\\n\" + \r\n\"\t\t\t\t\t\t\t\t\t\t<div id=\\\"##id##ModalCloseButtonContainer\\\" class=\\\"nsEditorModalCloseButtonContainer\\\">\\r\\n\" + \r\n\"\t\t\t\t\t\t\t\t\t\t\t<button type=\\\"button\\\" data-command=\\\"close\\\" class=\\\"nsEditorModalButton nsEditorModalCloseButton\\\" aria-label=\\\"Close\\\" title=\\\"Close\\\">\\r\\n\" + \r\n\"\t\t\t\t\t\t\t\t\t\t\t\t<svg xmlns=\\\"http://www.w3.org/2000/svg\\\" viewBox=\\\"0 0 15.74 15.74\\\">\\r\\n\" + \r\n\"\t\t\t\t\t\t\t\t\t\t\t\t\t<g>\\r\\n\" + \r\n\"\t\t\t\t\t\t\t\t\t\t\t\t\t\t<path d=\\\"M14.15,11.63l5.61,5.61a1.29,1.29,0,0,1,.38.93,1.27,1.27,0,0,1-.4.93,1.25,1.25,0,0,1-.92.4,1.31,1.31,0,0,1-.94-.4l-5.61-5.61L6.67,19.1a1.31,1.31,0,0,1-.94.4,1.24,1.24,0,0,1-.92-.4,1.27,1.27,0,0,1-.4-.93,1.33,1.33,0,0,1,.38-.93l5.61-5.63L4.79,6a1.26,1.26,0,0,1-.38-.93,1.22,1.22,0,0,1,.4-.92,1.28,1.28,0,0,1,.92-.39,1.38,1.38,0,0,1,.94.38l5.61,5.61,5.61-5.61a1.33,1.33,0,0,1,.94-.38,1.26,1.26,0,0,1,.92.39,1.24,1.24,0,0,1,.4.92,1.29,1.29,0,0,1-.39.93L17,8.81l-2.8,2.82Z\\\" transform=\\\"translate(-4.41 -3.76)\\\"/>\\r\\n\" + \r\n\"\t\t\t\t\t\t\t\t\t\t\t\t\t</g>\\r\\n\" + \r\n\"\t\t\t\t\t\t\t\t\t\t\t\t</svg>\\r\\n\" + \r\n\"\t\t\t\t\t\t\t\t\t\t\t</button>\\r\\n\" + \r\n\"\t\t\t\t\t\t\t\t\t\t</div>\\r\\n\" + \r\n\"\t\t\t\t\t\t\t\t\t</div>\\r\\n\" + \r\n\"\t\t\t\t\t\t\t\t\t<div id=\\\"##id##ContentContainer\\\" class=\\\"nsEditorModalContentContainer \" + this.__config.contentCSSClass + \"\\\">\\r\\n\" + \r\n\"\t\t\t\t\t\t\t\t\t\t<span id=\\\"##id##ContentMask\\\" class=\\\"nsEditorModalContentMask\\\"></span>\\r\\n\" +\r\n\"\t\t\t\t\t\t\t\t\t\t<div id=\\\"##id##Content\\\" class=\\\"nsEditorModalContent\\\">\\r\\n\" +\r\n\"\t\t\t\t\t\t\t\t\t\t</div>\\r\\n\" +\r\n\"\t\t\t\t\t\t\t\t\t</div>\\r\\n\" + \r\n\"\t\t\t\t\t\t\t\t\t \" + (htmlFooter ? \"<div class=\\\"nsEditorModalFooter\\\"></div>\" : \"\")  + \" \\r\\n\" +\r\n\"\t\t\t\t\t\t\t\t</div>\\r\\n\" + \r\n\"\t\t\t\t\t\t\t</div>\\r\\n\" + \r\n\"\t\t\t\t\t\t</div>\";\r\n\t\t\t\r\n\t\t\thtml = html.replaceAll(\"##id##\",this.__id); \r\n\t\t\thtml = html.replaceAll(\"##name##\",this.__nsParentPluggin.name);\r\n\t\t\tvar compOuterContainer = this.util.getElementFromHtml(html);\r\n\t\t\tvar compContent = compOuterContainer.querySelector(\".nsEditorModalContent\");\r\n\t\t\tthis.__addCompInParent(compContent,htmlContent)\r\n\t\t\tvar compFooter = compOuterContainer.querySelector(\".nsEditorModalFooter\");\r\n\t\t\tif(compFooter)\r\n\t\t\t{\r\n\t\t\t\tthis.__addCompInParent(compFooter,htmlFooter)\r\n\t\t\t}\r\n\t\t\tvar btnClose = compOuterContainer.querySelector(\".nsEditorModalCloseButton\");\r\n\t\t\tthis.util.addEvent(btnClose,\"click\",this.close.bind(this));\r\n\t\t\tvar compDragHandle = compOuterContainer.querySelector(\".nsEditorModalDragHandle\");\r\n\t\t\tthis.util.addEvent(compDragHandle,\"mousedown\",this.__titleBarMouseDownHandler.bind(this));\r\n\t\t\treturn compOuterContainer;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__addCompInParent = function(parent,content)\r\n\t\t{\r\n\t\t\tif(this.util.isString(content))\r\n\t\t\t{\r\n\t\t\t\tparent.innerHTML = content;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tparent.appendChild(content);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__initialize();\r\n\t};\r\n\t\r\n\tNSEditor.prototype.registerUtil(\"modal\",NSEditorModal);\r\n\t\r\n\treturn NSEditorModal;\r\n})();\r\nnsModuleExport(this,\"NSEditorModal\",NSEditorModal); var NSEditorInlinePopup = (function()\r\n{\r\n\tvar NSEditorInlinePopup = function(nsEditor,nsParentPluggin,setting)\r\n\t{\r\n\t\tthis.__nsEditor = nsEditor;\r\n\t\tthis.__nsParentPluggin = nsParentPluggin;\r\n\t\tthis.__setting = setting;\r\n\t\tthis.util = nsEditor.util;\r\n\t\tthis.editorUtil = nsEditor.editorUtil;\r\n\t\t\r\n\t\tthis.__divModalMask = null;\r\n\t\tthis.__divDragMask = null;\r\n\t\tthis.__id = null;\r\n\t\tthis.__compOuterContainer = null;\r\n\t\tthis.__originalValue = null;\r\n\t\tthis.__objDrag = null;\r\n\t\tthis.__docClickRef = null;\r\n\t\t\r\n\t\tthis.__initialize = function()\r\n\t\t{\r\n\t\t\tthis.__setSetting();\r\n\t\t\tthis.__componentsInitialized();\r\n\t\t};\r\n\t\t\r\n\t\tthis.__setSetting = function()\r\n\t\t{\r\n\t\t\tif(!this.__setting)\r\n\t\t\t{\r\n\t\t\t\tthrow this.util.throwNSError(\"NSEditorInlinePopup\",\"Setting for Pluggin \" + this.__nsParentPluggin.name + \" is not defined\");\r\n\t\t\t}\r\n\t\t\tvar config = this.__setting;\r\n\t\t\tif(!config.contentCallback)\r\n\t\t\t{\r\n\t\t\t\tthrow this.util.throwNSError(\"NSEditorInlinePopup\",\"ContentCallback in setting for Pluggin \" + this.__nsParentPluggin.name + \" is not defined\");\r\n\t\t\t}\r\n\t\t\tthis.__config = {\r\n\t\t\t\t\t\t\t\tcontainer: config[\"container\"] || this.__nsEditor.__getFixedComp(),\r\n\t\t\t\t\t\t\t\ttitle: config[\"title\"] || \"\",\r\n\t\t\t\t\t\t\t\tenableArrow: this.util.isUndefinedOrNull(config[\"enableArrow\"]) ? true : Boolean.parse(config[\"enableArrow\"]),\r\n\t\t\t\t\t\t\t\tcontentCallback: this.util.getFunction(config[\"contentCallback\"])\r\n\t\t\t\t\t\t    };\r\n\t\t\t\r\n\t\t};\r\n\t\t\r\n\t\tthis.__componentsInitialized = function()\r\n\t\t{\r\n\t\t\tthis.__createComponents();\r\n\t\t\tthis.__nsEditor.__listenInternalEvent(\"resized change changePlace readonly\",this.hide.bind(this));\r\n\t\t\tthis.__nsEditor.__listenInternalEvent(\"destroy\",this.destroy.bind(this));\r\n\t\t};\r\n\t\t\r\n\t\tthis.__createComponents = function()\r\n\t\t{\r\n\t\t\tthis.__id = this.__nsEditor.getID() + (this.__nsParentPluggin.name ? this.__nsParentPluggin.name : \"\") + \"EditorModal\";\r\n\t\t\tthis.destroy();\r\n\t\t\tthis.__compOuterContainer = this.__getContainer();\r\n\t\t\tthis.__config.container.appendChild(this.__compOuterContainer);\r\n\t\t\tvar compArrow = this.__compOuterContainer.querySelector(\".nsEditorInlinePopupArrowUp\");\r\n\t\t\t//11 --> border of arrow\r\n\t\t\tcompArrow.style.marginLeft = ((this.__compOuterContainer.offsetWidth / 2) - 11) + \"px\";\r\n\t\t\tthis.__hide();\r\n\t\t\tthis.util.addEvent(this.__compOuterContainer,\"blur\",this.__containerBlurHandler.bind(this),true);\r\n\t\t\tthis.util.addEvent(this.__compOuterContainer,\"click\",this.editorUtil.stopEvent.bind(this.editorUtil));\r\n\t\t};\r\n\t\t\t\t\r\n\t\tthis.show = function(element,event,offset,direction) \r\n\t\t{\r\n\t\t\tthis.__showAtElement(element,event,offset,direction);\r\n\t\t\tthis.__nsEditor.__dispatchInternalEvent(\"inlinePopupShow\",{inlinePopup:this});\r\n\t\t};\r\n\t\t\r\n\t\tthis.hide = function()\r\n\t\t{\r\n\t\t\tif (!this.isHidden()) \r\n\t\t\t{\r\n\t\t\t\tthis.__hide();\r\n\t\t\t\tthis.__nsEditor.__dispatchInternalEvent(\"inlinePopupHide\",{inlinePopup:this});\r\n\t\t    }\r\n\t\t};\r\n\t\t\t\t\r\n\t\tthis.isHidden = function()\r\n\t\t{\r\n\t\t\tif(!this.isDestroyed())\r\n\t\t\t{\r\n\t\t\t\treturn this.util.hasStyleClass(this.__compOuterContainer,\"nsEditorInlinePopupHide\")\r\n\t\t\t}\r\n\t\t\treturn true;\r\n\t\t};\r\n\t\t\r\n\t\tthis.isDestroyed = function()\r\n\t\t{\r\n\t\t\tif(this.__compOuterContainer && this.__compOuterContainer.parentElement)\r\n\t\t\t{\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\treturn true;\r\n\t\t};\r\n\t\t\r\n\t\tthis.getHorizontalSeparator = function(id)\r\n\t\t{\r\n\t\t\tvar div = this.util.createDiv(id,\"nsEditorInlinePopupHorizontalSeparator\");\r\n\t\t\treturn div;\r\n\t\t};\r\n\t\t\r\n\t\tthis.getMenuItem = function(id,cssClass,content,toolTipContent,subMenu,handler)\r\n\t\t{\r\n\t\t\tvar button = this.__createButton(id,cssClass,content,toolTipContent);\r\n\t\t\tif(subMenu && subMenu.length > 0)\r\n\t\t\t{\r\n\t\t\t\tthis.util.addStyleClass(button,\"nsEditorInlinePopupButtonDropdown\");\r\n\t\t\t\tvar divContainer = this.util.createDiv(null,\"nsEditorInlinePopupButtonDropdownContainer\");\r\n\t\t\t\tdivContainer.appendChild(button);\r\n\t\t\t\tvar divDropdownCon = this.util.createDiv(null,\"nsEditorInlinePopupDropdownContainer\");\r\n\t\t\t\tvar compDropdown = this.util.createElement(\"ul\",null,\"nsEditorInlinePopupButtonDropdown\");\r\n\t\t\t\tfor(var count = 0;count < subMenu.length;count++)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar li = subMenu[count];\r\n\t\t\t\t\tcompDropdown.appendChild(li);\r\n\t\t\t\t}\r\n\t\t\t\tdivDropdownCon.appendChild(compDropdown);\r\n\t\t\t\tdivContainer.appendChild(divDropdownCon);\r\n\t\t\t\tthis.util.addEvent(button,\"click\",this.__btnHandlerWithSubMenu.bind(this,button,divContainer,divDropdownCon,handler));\r\n\t\t\t\treturn divContainer;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthis.util.addEvent(button,\"click\",this.__btnHandler.bind(this,button,handler));\r\n\t\t\t}\r\n\t\t\treturn button;\r\n\t\t};\r\n\t\t\r\n\t\tthis.getSubMenuItem = function(id,cssClass,content,toolTipContent,handler)\r\n\t\t{\r\n\t\t\tvar li = this.util.createElement(\"li\",id,\"nsEditorInlinePopupButtonDropdownItem\");\r\n\t\t\tif(cssClass)\r\n\t\t\t{\r\n\t\t\t\tthis.util.addStyleClass(li,cssClass);\r\n\t\t\t}\r\n\t\t\tvar anchor = this.util.createElement(\"a\",null,\"nsEditorInlinePopupButtonDropdownItemContent\");\r\n\t\t\tthis.__setAttribute(anchor,{tabindex: \"-1\", role: \"option\"});\r\n\t\t\tif(content)\r\n\t\t\t{\r\n\t\t\t\tthis.__addCompInParent(anchor,content)\r\n\t\t\t}\r\n\t\t\tif(toolTipContent)\r\n\t\t\t{\r\n\t\t\t\tvar toolTip = this.__createTooltip(toolTipContent);\r\n\t\t\t\t//anchor.appendChild(toolTip);\r\n\t\t\t}\r\n\t\t\tli.appendChild(anchor);\r\n\t\t\tthis.util.addEvent(li,\"click\",this.__btnSubMenuHandler.bind(this,li,handler));\r\n\t\t\treturn li;\r\n\t\t};\r\n\t\t\r\n\t\tthis.destroy = function()\r\n\t\t{\r\n\t\t\tif(this.__compOuterContainer && this.__compOuterContainer.parentElement)\r\n\t\t\t{\r\n\t\t\t\tthis.__compOuterContainer.parentElement.removeChild(this.__compOuterContainer);\r\n\t\t\t\tthis.__compOuterContainer = null;\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__createButton = function(id,cssClass,content,toolTipContent)\r\n\t\t{\r\n\t\t\tvar button = this.util.createElement(\"button\",id,\"nsEditorInlinePopupButton\");\r\n\t\t\tvar objAttribute = {type: \"button\",tabindex: \"-1\",role:\"button\",\"data-title\": (toolTip ? toolTip : \"\")};\r\n\t\t\tthis.__setAttribute(button,objAttribute);\r\n\t\t\tif(cssClass)\r\n\t\t\t{\r\n\t\t\t\tthis.util.addStyleClass(button,cssClass);\r\n\t\t\t}\r\n\t\t\tif(content)\r\n\t\t\t{\r\n\t\t\t\tthis.__addCompInParent(button,content)\r\n\t\t\t}\r\n\t\t\tif(toolTipContent)\r\n\t\t\t{\r\n\t\t\t\tvar toolTip = this.__createTooltip(toolTipContent);\r\n\t\t\t\tbutton.appendChild(toolTip);\r\n\t\t\t}\r\n\t\t\treturn button;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__createTooltip = function(toolTipContent)\r\n\t\t{\r\n\t\t\tvar toolTip = this.util.createElement(\"span\",null,\"nsEditorInlinePopupButtonTooltip\");\r\n\t\t\tvar toolTipText = this.util.createElement(\"span\",null,\"nsEditorInlinePopupButtonTooltipText\");\r\n\t\t\ttoolTipText.innerHTML = toolTipContent;\r\n\t\t\ttoolTip.appendChild(toolTipText);\r\n\t\t\t\r\n\t\t\treturn toolTip;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__btnHandler = function(button,handler,event)\r\n\t\t{\r\n\t\t\tevent = this.util.getEvent(event);\r\n\t\t\tthis.__commonBtnHandler(button,event);\r\n\t\t\thandler && handler(event,button);\r\n\t\t\tthis.hide();\r\n\t\t};\r\n\t\t\r\n\t\tthis.__btnHandlerWithSubMenu = function(button,container,dropdownContainer,handler,event)\r\n\t\t{\r\n\t\t\tevent = this.util.getEvent(event);\r\n\t\t\tvar self = this;\r\n\t\t\tthis.__commonBtnHandler(button,event,function(btn){\r\n\t\t\t\tif(btn != button)\r\n\t\t\t\t{\r\n\t\t\t\t\t//var con = btn.parentElement;\r\n\t\t\t\t\tself.util.removeStyleClass(btn,\"nsEditorInlinePopupButtonOpen\");\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t\tvar isDropdownOpen = this.util.hasStyleClass(dropdownContainer,\"nsEditorInlinePopupDropdownContainerVisible\");\r\n\t\t\tif(isDropdownOpen)\r\n\t\t\t{\r\n\t\t\t\tthis.util.removeStyleClass(button,\"nsEditorInlinePopupButtonOpen\");\r\n\t\t\t\tthis.util.removeStyleClass(dropdownContainer,\"nsEditorInlinePopupDropdownContainerVisible\");\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthis.__resetMenuButtons(true);\r\n\t\t\t\tthis.__resetSubMenuButtons();\r\n\t\t\t\tthis.util.addStyleClass(button,\"nsEditorInlinePopupButtonOpen\");\r\n\t\t\t\tthis.util.addStyleClass(dropdownContainer,\"nsEditorInlinePopupDropdownContainerVisible\");\r\n\t\t\t}\r\n\t\t\thandler && handler(event,button);\r\n\t\t};\r\n\t\t\r\n\t\tthis.__btnSubMenuHandler = function(button,handler,event)\r\n\t\t{\r\n\t\t\tevent = this.util.getEvent(event);\r\n\t\t\tthis.__commonBtnHandler(button,event);\r\n\t\t\tthis.hide();\r\n\t\t\thandler && handler(event,button);\r\n\t\t};\r\n\t\t\r\n\t\tthis.__commonBtnHandler = function(button,event,callback)\r\n\t\t{\r\n\t\t\tvar arrButton = this.__compOuterContainer.querySelectorAll(\".nsEditorInlinePopupButton\");\r\n\t\t\tfor(var count = 0;count < arrButton.length;count++)\r\n\t\t\t{\r\n\t\t\t\tthis.util.removeStyleClass(arrButton[count],\"nsEditorInlinePopupButtonActive\");\r\n\t\t\t\tcallback && callback(arrButton[count]);\r\n\t\t\t}\r\n\t\t\tthis.util.addStyleClass(button,\"nsEditorInlinePopupButtonActive\");\r\n\t\t\tthis.editorUtil.stopEvent(event);\r\n\t\t};\r\n\t\t\r\n\t\tthis.__containerBlurHandler = function(event)\r\n\t\t{\r\n\t\t\tevent = this.util.getEvent(event);\r\n\t\t\tvar target = event.target;\r\n\t\t\tif(!this.__compOuterContainer.contains(target))\r\n\t\t\t{\r\n\t\t\t\tthis.editorUtil.stopEvent();\r\n\t\t\t\tthis.hide();\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__setAttribute = function(element,item)\r\n\t\t{\r\n\t\t\tfor(var key in item)\r\n\t\t\t{\r\n\t\t\t\telement.setAttribute(key,item[key].toString());\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__getContainer = function()\r\n\t\t{\r\n\t\t\tvar html = \"<div id=\\\"##id##InlinePopUpOuterContainer\\\" class=\\\"nsEditorInlinePopup nsEditorInlinePopupFor##name##\\\">\\r\\n\" + \r\n\"\t\t\t\t\t\t\t\" + (this.__config.enableArrow ? \"<div id=\\\"##id##InlinePopUpArrow\\\" class=\\\"nsEditorInlinePopupArrow nsEditorInlinePopupArrowUp\\\"></div>\" : \"\") + \"\\r\\n\" +\r\n\"\t\t\t\t\t\t\t<div id=\\\"##id##InlinePopUpContentContainer\\\" class=\\\"nsEditorInlinePopupContentContainer\\\"></div> \\r\\n\" +\r\n\"\t\t\t\t\t\t</div>\";\r\n\t\t\thtml = html.replaceAll(\"##id##\",this.__id);\r\n\t\t\thtml = html.replaceAll(\"##name##\",(this.__nsParentPluggin.name ? this.__nsParentPluggin.name : \"\"));\r\n\t\t\tvar compOuterContainer = this.util.getElementFromHtml(html);\r\n\t\t\tcompOuterContainer.setAttribute(\"tabindex\",\"-1\");\r\n\t\t\tvar compContent = compOuterContainer.querySelector(\".nsEditorInlinePopupContentContainer\");\r\n\t\t\tvar content = this.__config.contentCallback(compContent,this,this.__nsParentPluggin);\r\n\t\t\tthis.__addCompInParent(compContent,content);\r\n\t\t\treturn compOuterContainer;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__addCompInParent = function(parent,content)\r\n\t\t{\r\n\t\t\tif(content)\r\n\t\t\t{\r\n\t\t\t\tif(this.util.isString(content))\r\n\t\t\t\t{\r\n\t\t\t\t\tparent.innerHTML = content;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tparent.appendChild(content);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__hide = function()\r\n\t\t{\r\n\t\t\tif (!this.isHidden()) \r\n\t\t\t{\r\n\t\t\t\tif(this.__docClickRef)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.util.removeEvent(this.__nsEditor.__dom.doc,\"click\",this.__docClickRef);\r\n\t\t\t\t\tthis.__docClickRef = null;\r\n\t\t\t\t}\r\n\t\t\t\tthis.__resetMenuButtons();\r\n\t\t\t\tthis.__resetSubMenuButtons();\r\n\t\t\t\tthis.util.addStyleClass(this.__compOuterContainer,\"nsEditorInlinePopupHide\");\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__showAtElement = function(element,event,offset,direction) \r\n\t\t{\r\n\t\t\tthis.util.removeStyleClass(this.__compOuterContainer,\"nsEditorInlinePopupHide\");\r\n\t\t\tvar win = this.__nsEditor.__dom.win;\r\n\t\t\tvar doc = this.__nsEditor.__dom.doc;\r\n\t\t\tvar compTextArea = this.__nsEditor.__compTextArea;\r\n\t\t\tvar self = this;\r\n\t\t\tvar offsetFunc = function(el) \r\n\t\t\t{\r\n\t\t\t    var rect = el.getBoundingClientRect();\r\n\t\t\t    var scrollLeft = win.pageXOffset || doc.documentElement.scrollLeft;\r\n\t\t\t    var scrollTop = win.pageYOffset || doc.documentElement.scrollTop;\r\n\t\t\t    var textAreaRect = {left: 0,top: 0};\r\n\t\t\t    if(!self.__nsEditor.__isModeTextArea())\r\n\t\t\t    {\r\n\t\t\t    \ttextAreaRect = compTextArea.getBoundingClientRect();\r\n\t\t\t    }\r\n\t\t\t    //return { top: rect.top + scrollTop + textAreaRect.top, left: rect.left + scrollLeft  + textAreaRect.left};\r\n\t\t\t    //looks like rect is including scroll position\r\n\t\t\t    var width = self.__compOuterContainer.offsetWidth;\r\n\t\t\t    //11 is top of arrow\r\n\t\t\t    return { top: rect.top + textAreaRect.top + (11/2) , left: (rect.left + textAreaRect.left - (width/4))};\r\n\t\t\t}\r\n\t\t\tdirection = direction ? direction : \"bottom\";\r\n\t\t\toffset = offset ? offset : {left: 0,top: 0};\r\n\t\t\toffset.left = offset.left ? offset.left : 0;\r\n\t\t\toffset.top = offset.top ? offset.top : 0;\r\n\t\t\t//var eventOffset = this.util.getEventPosition(event);\r\n\t\t\tvar eventOffset = offsetFunc(element);\r\n\t\t\tthis.__compOuterContainer.style.left = (eventOffset.left + offset.left) + \"px\";\r\n\t\t\tthis.__compOuterContainer.style.top = (eventOffset.top + offset.top + element.offsetHeight) + \"px\";\r\n\t\t\tif(!this.__docClickRef)\r\n\t\t\t{\r\n\t\t\t\tthis.__docClickRef = this.__documentClickHandler.bind(this);\r\n\t\t\t\tthis.util.addEvent(this.__nsEditor.__dom.doc,\"click\",this.__docClickRef);\r\n\t\t\t}\r\n\t\t\t/*var self = this;\r\n\t\t\tsetTimeout(function() {\r\n\t\t\t\tself.util.removeStyleClass(self.__compOuterContainer,\"nsEditorInlinePopupHide\");\r\n\t\t\t}, 50);*/\r\n\t\t\t//this.__compOuterContainer.focus();\r\n\t\t\t//this.editorUtil.setElementPosition(this.__compOuterContainer,element,direction);\r\n\t    };\r\n\t    \r\n\t    this.__documentClickHandler = function(event)\r\n\t    {\r\n\t    \tthis.hide();\r\n\t    };\r\n\t    \r\n\t    this.__resetMenuButtons = function(excludeActive)\r\n\t\t{\r\n\t    \tthis.__resetBtn(\"nsEditorInlinePopupButtonOpen\");\r\n\t    \t!excludeActive && this.__resetBtn(\"nsEditorInlinePopupButtonActive\");\r\n\t\t};\r\n\t\t\r\n\t\tthis.__resetSubMenuButtons = function()\r\n\t\t{\r\n\t\t\tthis.__resetBtn(\"nsEditorInlinePopupDropdownContainerVisible\");\r\n\t\t};\r\n\t\t\r\n\t\tthis.__resetBtn = function(cssClass)\r\n\t\t{\r\n\t\t\tvar arrBtn = this.__compOuterContainer.querySelectorAll(\".\" + cssClass);\r\n\t\t\tfor(var count = 0;count < arrBtn.length;count++)\r\n\t\t\t{\r\n\t\t\t\tthis.util.removeStyleClass(arrBtn[count],cssClass);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__initialize();\r\n\t};\r\n\t\r\n\tNSEditor.prototype.registerUtil(\"inlinePopup\",NSEditorInlinePopup);\r\n\t\r\n\treturn NSEditorInlinePopup;\r\n})();\r\nnsModuleExport(this,\"NSEditorInlinePopup\",NSEditorInlinePopup); var NSEditorUIFunc = (function()\r\n{\r\n\tvar NSEditorUIFunc = function(nsEditor,nsParentPluggin,setting)\r\n\t{\r\n\t\tthis.__nsEditor = nsEditor;\r\n\t\tthis.__nsParentPluggin = nsParentPluggin;\r\n\t\tthis.__setting = setting;\r\n\t\t\r\n\t\tthis.horizontalAlign = {left:\"left\",right:\"right\",center:\"center\",justify:\"justify\"};\r\n\t\tthis.verticalAlign = {top:\"top\",middle:\"middle\",bottom:\"bottom\",normal:\"delete\"};\r\n\t\t\r\n\t\tthis.__initialize = function()\r\n\t\t{\r\n\t\t};\r\n\t\t\r\n\t\t//horizontal Align section start\r\n\t\tthis.setHorizontalAlignForNodes = function(alignment,arrNodes)\r\n\t\t{\r\n\t\t\tthis.setAlignmentForNodes(alignment,arrNodes,this.horizontalAlign,\"textAlign\");\r\n\t\t};\r\n\t\t\r\n\t\tthis.setHorizontalAlignForNode = function(alignment,node)\r\n\t\t{\r\n\t\t\tthis.setAlignmentForNode(this.horizontalAlign,alignment,node,\"textAlign\");\r\n\t\t};\r\n\t\t\r\n\t\tthis.clearHorizontalAlign = function(node)\r\n\t\t{\r\n\t\t\tthis.clearAlign(node,\"textAlign\");\r\n\t\t};\r\n\t\t//horizontal Align section ends\r\n\t\t\r\n\t\t//vertical Align section starts\r\n\t\tthis.setVerticalAlignForNodes = function(alignment,arrNodes)\r\n\t\t{\r\n\t\t\tvar callback = null;\r\n\t\t\tif(alignment == \"normal\")\r\n\t\t\t{\r\n\t\t\t\tvar self = this;\r\n\t\t\t\tcallback = function(node)\r\n\t\t\t\t{\r\n\t\t\t\t\tif(node) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tself.clearVerticalAlign(node);\r\n\t\t            }\r\n\t\t\t\t};\r\n\t\t\t}\r\n\t\t\tthis.setAlignmentForNodes(alignment,arrNodes,this.verticalAlign,\"verticalAlign\",callback)\r\n\t\t};\r\n\t\t\r\n\t\tthis.setVerticalAlignForNode = function(alignment,node)\r\n\t\t{\r\n\t\t\tthis.setAlignmentForNode(this.verticalAlign,alignment,node,\"verticalAlign\");\r\n\t\t};\r\n\t\t\r\n\t\tthis.clearVerticalAlign = function(node)\r\n\t\t{\r\n\t\t\tthis.clearAlign(node,\"verticalAlign\");\r\n\t\t};\r\n\t\t//vertical Align section ends\r\n\t\t\r\n\t\tthis.setAlignmentForNodes = function(alignment,arrNodes,objAlign,styleProp,callback)\r\n\t\t{\r\n\t\t\tvar self = this;\r\n\t\t\tvar doc = this.__nsEditor.__getDocument();\r\n\t\t\tvar win = this.__nsEditor.__getWindow();\r\n    \t\tvar textArea = this.__nsEditor.__getTextArea();\r\n    \t\tcallback = callback || function(node)\r\n\t\t\t{\r\n\t\t\t\tif(node) \r\n\t\t\t\t{\r\n\t\t\t\t\tvar parent = self.util.findParentByCallback(node,function(paramNode) \r\n\t\t\t\t\t{ \r\n\t\t\t\t\t\treturn self.editorUtil.isBlock(paramNode,win); \r\n\t\t\t\t\t},textArea);\r\n\t\t            if (!parent) \r\n\t\t            {\r\n\t\t            \tparent = self.editorUtil.wrapAllInlineSiblings(node,self.__nsEditor.__config.enterElement);\r\n\t\t            }\r\n\t\t            self.setAlignmentForNode(objAlign,alignment,parent,styleProp);\r\n\t            }\r\n\t\t\t};\r\n\t\t\tif(arrNodes && arrNodes.length)\r\n\t\t\t{\r\n\t\t\t\tfor(var count = 0;count < arrNodes.length;count++)\r\n\t\t\t\t{\r\n\t\t\t\t\tcallback(arrNodes[count]);\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.selection.loopSelectedNodes(callback);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.setAlignmentForNode = function(objAlign,alignment,node,styleProp)\r\n\t\t{\r\n\t\t\tvar doc = this.__nsEditor.__getDocument();\r\n\t\t\tvar win = this.__nsEditor.__getWindow();\r\n    \t\tvar textArea = this.__nsEditor.__getTextArea();\r\n\t\t\tif(alignment && this.util.isElement(node) && this.editorUtil.isNode(node,win))\r\n\t\t\t{\r\n\t\t\t\tthis.clearAlign(node,styleProp);\r\n\t\t\t\tvar align = objAlign[alignment.toLowerCase()];\r\n\t\t\t\tif(align)\r\n\t\t\t\t{\r\n\t\t\t\t\tnode.style[styleProp] = align;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.clearAlign = function(node,styleProp)\r\n\t\t{\r\n\t\t\tvar self = this;\r\n\t\t\tvar clearAlign = function(paramNode)\r\n\t\t\t{\r\n\t\t\t\tif (self.util.isElement(paramNode)) \r\n\t\t\t\t{\r\n\t\t\t\t\tif (paramNode.style[styleProp]) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tparamNode.style[styleProp] = \"\";\r\n\t\t\t\t\t\tif (!paramNode.style.cssText.trim().length) \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tparamNode.removeAttribute(\"style\");\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\tif(node)\r\n\t\t\t{\r\n\t\t\t\tvar arrChild = node.childNodes;\r\n\t\t\t\tfor(var count = 0;count < arrChild.length;count++)\r\n\t\t\t\t{\r\n\t\t\t\t\tclearAlign(arrChild[count]);\r\n\t\t\t\t}\r\n\t\t\t\tclearAlign(node);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__initialize();\r\n\t};\r\n\t\r\n\tNSEditor.prototype.registerUtil(\"uiFunc\",NSEditorUIFunc);\r\n\t\r\n\treturn NSEditorUIFunc;\r\n})();\r\nnsModuleExport(this,\"NSEditorUIFunc\",NSEditorUIFunc);var NSEditorFullScreen = (function()\r\n{\t\r\n\tvar NSEditorFullScreen = function(nsEditor)\r\n\t{\r\n\t\tthis.__nsEditor = nsEditor;\r\n\t\tthis.util = nsEditor.util;\r\n\t\t\r\n\t\tthis.__orignalSetting = {height:null,width: null,changed: false};\r\n\t\t\r\n\t\tthis.setSettings = function()\r\n\t\t{\r\n\t\t\tvar self = this;\r\n\t\t\tthis.__nsEditor.__toolBarButton[\"fullScreen\"] = {html:\"<i class='ns-icon ns-editor-expand' aria-hidden='true'></i>\",tooltip:\"Full Screen\",showAsMenu: true,\r\n\t\t\t\t\t\t\t\t\t\t\t\t  checkDisability: function(toolBarKey,toolBarItem,item,itemKey,isDefaultDisabled)\r\n\t\t\t\t\t\t\t\t\t\t\t\t  {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t  //it should enabled every time\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t  return !isDefaultDisabled;\r\n\t\t\t\t\t\t\t\t\t\t\t\t  },\r\n\t\t\t\t\t\t\t\t\t\t\t\t  click:function(item,key,event)\r\n\t\t\t\t\t\t\t\t\t\t\t\t  {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t  self.toggle();\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t  event = self.util.getEvent();\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t  var iTag = event.target;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t  if(event.target.nodeName.toLowerCase() === \"button\")\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t  {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  iTag = event.target.children[0];\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t  }\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t  if(iTag)\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t  {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  if(self.util.hasStyleClass(iTag,\"ns-editor-expand\"))\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  self.util.removeStyleClass(iTag,\"ns-editor-expand\");\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  self.util.addStyleClass(iTag,\"ns-editor-collapse\");\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  }\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  else\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  self.util.addStyleClass(iTag,\"ns-editor-expand\");\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  self.util.removeStyleClass(iTag,\"ns-editor-collapse\");\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  }\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t  }\r\n\t\t\t\t\t\t\t\t\t\t\t\t  }};\r\n\t\t};\r\n\t\t\r\n\t\tthis.initialize = function()\r\n\t\t{\r\n\t\t\tthis.__nsEditor.__listenInternalEvent(\"toggleFullSize\",this.toggle.bind(this));\r\n\t\t};\r\n\t\t\r\n\t\tthis.componentsInitialized = function()\r\n\t\t{\r\n\t\t\t\r\n\t\t};\r\n\t\t\r\n\t\tthis.resized = function(event)\r\n\t\t{\r\n\t\t\tif(this.isFullScreen())\r\n\t\t\t{\r\n\t\t\t\tthis.__resizeContainer(false);\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\t\r\n\t\t};\r\n\t\t\r\n\t\tthis.toggle = function()\r\n\t\t{\r\n\t\t\tthis.isFullScreen() ? this.restore() : this.maximize();\r\n\t\t};\r\n\t\t\r\n\t\tthis.isFullScreen = function()\r\n\t\t{\r\n\t\t\treturn this.util.hasStyleClass(this.__nsEditor.__divOuterContainer,\"nsEditorFullScreen\");\r\n\t\t};\r\n\t\t\r\n\t\tthis.maximize = function()\r\n\t\t{\r\n\t\t\tif(!this.isFullScreen())\r\n\t\t\t{\r\n\t\t\t\tvar con = this.__nsEditor.__divOuterContainer;\r\n\t\t\t\tvar zIndex = this.util.getMaxZIndex(con);\r\n\t\t\t\tif(zIndex > 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tcon.style.zIndex = zIndex + 1;\r\n\t\t\t\t}\r\n\t\t\t\tthis.util.addStyleClass(con,\"nsEditorFullScreen\");\r\n\t\t\t\tthis.__setParentsPosition(false);\r\n\t            this.__resizeContainer(false);\r\n\t            this.__nsEditor.__dispatchInternalEvent(NSEditor.EVENT_MAXIMIZED);\r\n\t            this.__nsEditor.__dispatchInternalEvent(\"resizeFullScreen\");\r\n\t\t\t\tthis.__nsEditor.__dispatchEvent(NSEditor.EVENT_MAXIMIZED);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.restore = function()\r\n\t\t{\r\n\t\t\tif(this.isFullScreen())\r\n\t\t\t{\r\n\t\t\t\tvar con = this.__nsEditor.__divOuterContainer;\r\n\t\t\t\tcon.style.zIndex = \"\";\r\n\t\t\t\tthis.util.removeStyleClass(con,\"nsEditorFullScreen\");\r\n\t\t\t\tthis.__setParentsPosition(true);\r\n\t            this.__resizeContainer(true);\r\n\t\t\t\tthis.__nsEditor.__dispatchInternalEvent(NSEditor.EVENT_RESTORED);\r\n\t\t\t\tthis.__nsEditor.__dispatchInternalEvent(\"resizeFullScreen\");\r\n\t\t\t\tthis.__nsEditor.__dispatchEvent(NSEditor.EVENT_RESTORED);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__setParentsPosition = function(isReset)\r\n\t\t{\r\n\t\t\tvar parent = this.__nsEditor.__divOuterContainer.parentNode;\r\n            while (parent && parent.nodeType !== Node.DOCUMENT_NODE) \r\n            {\r\n            \tisReset ? this.util.removeStyleClass(parent,\"nsEditorFullScreenParent\") : this.util.addStyleClass(parent,\"nsEditorFullScreenParent\");\r\n            \tparent = parent.parentNode;\r\n            }\r\n\t\t};\r\n\t\t\r\n\t\tthis.__resizeContainer = function(isReset)\r\n\t\t{\r\n\t\t\tvar container = this.__nsEditor.__divOuterContainer;\r\n\t\t\tif(isReset)\r\n\t\t\t{\r\n\t\t\t\tif(this.__orignalSetting.changed)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar item = {height:this.__orignalSetting.height || \"auto\",\r\n\t\t\t\t\t\t\t\twidth:this.__orignalSetting.width || \"auto\"};\r\n\t\t\t\t\tthis.util.css(container,item);\r\n\t\t\t\t\tthis.__orignalSetting = {height:null,width: null,changed: false};\r\n\t\t\t\t\tthis.__nsEditor.__resizeCallback(false);\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.__orignalSetting.height = this.util.getStyleValue(container,\"height\",false,true);\r\n\t\t\t\tthis.__orignalSetting.width = this.util.getStyleValue(container,\"width\",false,true);\r\n\t\t\t\tvar item = {height:this.__nsEditor.__context.innerHeight,width:this.__nsEditor.__context.innerWidth};\r\n\t\t\t\tthis.util.css(container,item);\r\n\t\t\t\tthis.__orignalSetting.changed = true;\r\n\t\t\t\tthis.__nsEditor.__resizeCallback(true);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tNSEditor.prototype.maximize = function()\r\n\t\t{\r\n\t\t\tvar objFullScreen = this.__pluginsInstances[\"fullScreen\"].instance;\r\n\t\t\tobjFullScreen.maximize();\r\n\t\t};\r\n\t\t\r\n\t\tNSEditor.prototype.restore = function()\r\n\t\t{\r\n\t\t\tvar objFullScreen = this.__pluginsInstances[\"fullScreen\"].instance;\r\n\t\t\tobjFullScreen.restore();\r\n\t\t};\r\n\t\t\r\n\t\tNSEditor.prototype.isFullScreen = function()\r\n\t\t{\r\n\t\t\tvar objFullScreen = this.__pluginsInstances[\"fullScreen\"].instance;\r\n\t\t\treturn objFullScreen.isFullScreen();\r\n\t\t};\r\n\t\t\r\n\t\tNSEditor.prototype.toggleFullScreen = function()\r\n\t\t{\r\n\t\t\tvar objFullScreen = this.__pluginsInstances[\"fullScreen\"].instance;\r\n\t\t\treturn objFullScreen.toggle();\r\n\t\t};\r\n\t\t\r\n\t};\r\n\tNSEditor.TOOLBAR_BUTTONS_FULLSCREEN = \"fullScreen\";\r\n\tNSEditor.EVENT_MAXIMIZED = \"maximized\";\r\n\tNSEditor.EVENT_RESTORED = \"restored\";\r\n\tNSEditor.prototype.registerPlugin(\"fullScreen\",NSEditorFullScreen);\r\n\t\r\n\treturn NSEditorFullScreen;\r\n})();\r\nnsModuleExport(this,\"NSEditorFullScreen\",NSEditorFullScreen);var NSEditorResize = (function()\r\n{\r\n\tvar NSEditorResize = function(nsEditor)\r\n\t{\r\n\t\tthis.__nsEditor = nsEditor;\r\n\t\tthis.util = nsEditor.util;\r\n\t\t\r\n\t\tthis.__enableResizeHorizontal = false;\r\n\t\tthis.__enableResizeVertical = false;\r\n\t\tthis.__objStart = {xPos:0,yPos:0,width:0,height:0,isResized: false};\r\n\t\tthis.__docMouseMoveRef = null;\r\n\t\tthis.__docMouseUpRef = null;\r\n\t\t\r\n\t\tthis.setSettings = function()\r\n\t\t{\r\n\t\t\tthis.__nsEditor.__config[\"enableResize\"] = Boolean.parse(this.__nsEditor.__setting[\"enableResize\"]);\r\n\t\t\tthis.__nsEditor.__config[\"resizeDirection\"] = this.__nsEditor.__setting[\"resizeDirection\"] || NSEditor.RESIZE_DIRECTION_VERTICAL;\r\n\t\t\tthis.__enableResizeHorizontal = (this.__nsEditor.__config[\"resizeDirection\"] == NSEditor.RESIZE_DIRECTION_BOTH || this.__nsEditor.__config[\"resizeDirection\"] == NSEditor.RESIZE_DIRECTION_HORIZONTAL);\r\n\t\t\tthis.__enableResizeVertical = (this.__nsEditor.__config[\"resizeDirection\"] == NSEditor.RESIZE_DIRECTION_BOTH || this.__nsEditor.__config[\"resizeDirection\"] == NSEditor.RESIZE_DIRECTION_VERTICAL);\r\n\t\t};\r\n\t\t\r\n\t\tthis.initialize = function()\r\n\t\t{\r\n\t\t};\r\n\t\t\r\n\t\tthis.componentsInitialized = function()\r\n\t\t{\r\n\t\t\tif(this.__nsEditor.__config.enableResize && this.__nsEditor.__config.height != \"auto\")\r\n\t\t\t{\r\n\t\t\t\tthis.__nsEditor.__handleVisibilityOfComponent(this.__nsEditor.__divFooterContainer,\"enableResize\");\r\n\t\t\t\tvar spanResizer = this.util.createElement(\"span\",this.__nsEditor.getID() + \"Resizer\",\"nsEditorResizer\");\r\n\t\t\t\tif(this.__nsEditor.__config[\"resizeDirection\"] !==  NSEditor.RESIZE_DIRECTION_BOTH)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.util.addStyleClass(spanResizer,\"nsEditorResizer\" + this.__nsEditor.__config[\"resizeDirection\"]);\r\n\t\t\t\t}\r\n\t\t\t\tspanResizer.innerHTML = \"\\u25E2\";\r\n\t\t\t\tthis.util.addEvent(spanResizer,\"mousedown touchstart\",this.__resizeMouseDownHandler.bind(this));\r\n\t\t\t\tthis.__nsEditor.__divFooterContainer.appendChild(spanResizer);\r\n\t\t\t\tvar self = this;\r\n\t\t\t\tthis.__nsEditor.__listenInternalEvent(NSEditor.EVENT_MAXIMIZED,function(event){\r\n\t\t\t\t\tself.util.addStyleClass(spanResizer,\"nsEditorComponentHidden\");\r\n\t\t\t\t});\r\n\t\t\t\tthis.__nsEditor.__listenInternalEvent(NSEditor.EVENT_RESTORED,function(event){\r\n\t\t\t\t\tself.util.removeStyleClass(spanResizer,\"nsEditorComponentHidden\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.resized = function(event)\r\n\t\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\t\r\n\t\t};\r\n\t\t\r\n\t\tthis.__resizeMouseDownHandler = function(event)\r\n\t\t{\r\n\t\t\tevent = this.util.getEvent(event);\r\n\t\t\tvar outerContainer = this.__nsEditor.__divOuterContainer;\r\n\t\t\tthis.__objStart = {xPos:event.clientX,yPos:event.clientY,width:outerContainer.offsetWidth,height:outerContainer.offsetHeight,isResized: true};\r\n\t\t\tif(!this.__docMouseMoveRef)\r\n\t\t\t{\r\n\t\t\t\tthis.__docMouseMoveRef = this.__docMouseMoveHandler.bind(this);\r\n\t\t\t\tthis.util.addEvent(this.__nsEditor.__context,\"mousemove touchmove\",this.__docMouseMoveRef);\r\n\t\t\t}\r\n\t\t\tif(!this.__docMouseUpRef)\r\n\t\t\t{\r\n\t\t\t\tthis.__docMouseUpRef = this.__docMouseUpHandler.bind(this);\r\n\t\t\t\tthis.util.addEvent(this.__nsEditor.__context,\"mouseup touchend\",this.__docMouseUpRef);\r\n\t\t\t}\r\n\t\t\tthis.__nsEditor.__dispatchInternalEvent(\"resizeStart\");\r\n\t\t\tevent.preventDefault();\r\n\t\t};\r\n\t\t\r\n\t\tthis.__docMouseMoveHandler = function(event)\r\n\t\t{\r\n\t\t\tevent = this.util.getEvent(event);\r\n\t\t\tif(this.__objStart.isResized)\r\n\t\t\t{\r\n\t\t\t\tif (this.__enableResizeHorizontal) \r\n\t\t\t\t{\r\n\t\t\t\t\tvar width = this.__objStart.width + event.clientX - this.__objStart.xPos;\r\n\t\t\t\t\tthis.__nsEditor.__width(width);\r\n\t            }\r\n\t\t\t\tif (this.__enableResizeVertical) \r\n\t\t\t\t{\r\n\t\t\t\t\tvar height = this.__objStart.height + event.clientY - this.__objStart.yPos;\r\n\t\t\t\t\tthis.__nsEditor.__height(height);\r\n\t            }\r\n\t\t\t\tthis.__nsEditor.__resizeCallback();\r\n\t\t\t\tthis.__nsEditor.__dispatchInternalEvent(\"resize\");\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__docMouseUpHandler = function(event)\r\n\t\t{\r\n\t\t\tif(this.__objStart.isResized)\r\n\t\t\t{\r\n\t\t\t\tthis.__objStart = {xPos:0,yPos:0,width:0,height:0,isResized: false};\r\n\t\t\t\tthis.__nsEditor.__dispatchInternalEvent(\"resizeEnd\");\r\n\t\t\t}\r\n\t\t\tif(this.__docMouseMoveRef)\r\n\t\t\t{\r\n\t\t\t\tthis.util.removeEvent(this.__nsEditor.__context,\"mousemove touchmove\",this.__docMouseMoveRef);\r\n\t\t\t\tthis.__docMouseMoveRef = null;\r\n\t\t\t}\r\n\t\t\tif(this.__docMouseUpRef)\r\n\t\t\t{\r\n\t\t\t\tthis.util.removeEvent(this.__nsEditor.__context,\"mouseup touchend\",this.__docMouseUpRef);\r\n\t\t\t\tthis.__docMouseUpRef = null;\r\n\t\t\t}\r\n\t\t};\r\n\t};\r\n\tNSEditor.RESIZE_DIRECTION_HORIZONTAL = \"horizontal\";\r\n\tNSEditor.RESIZE_DIRECTION_VERTICAL = \"vertical\";\r\n\tNSEditor.RESIZE_DIRECTION_BOTH = \"both\";\r\n\tNSEditor.prototype.registerPlugin(\"resize\",NSEditorResize);\r\n\t\r\n\treturn NSEditorResize;\r\n})();\r\nnsModuleExport(this,\"NSEditorResize\",NSEditorResize);var NSEditorLink = (function()\r\n{\t\r\n\tvar NSEditorLink = function(nsEditor)\r\n\t{\r\n\t\tthis.__nsEditor = nsEditor;\r\n\t\tthis.util = nsEditor.util;\r\n\t\tthis.editorUtil = nsEditor.editorUtil;\r\n\t\t\r\n\t\tthis.name = \"link\";\r\n\t\tthis.__config = null;\r\n\t\t\r\n\t\tthis.__modal = null;\r\n\t\tthis.__divBody = null;\r\n\t\tthis.__divFooter = null;\r\n\t\tthis.__id = null;\r\n\t\t\r\n\t\tthis.setSettings = function()\r\n\t\t{\r\n\t\t\tvar self = this;\r\n\t\t\tvar setting = this.__nsEditor.__setting.link;\r\n\t\t\tif(!setting)\r\n\t\t\t{\r\n\t\t\t\tsetting = {};\r\n\t\t\t}\r\n\t\t\tthis.__config = {\r\n\t\t\t\t\tprotocol: setting[\"protocol\"]\r\n\t\t\t    };\r\n\t\t\tthis.__nsEditor.__toolBarButton[\"link\"] = {html:\"<i class='ns-icon ns-editor-link' aria-hidden='true'></i>\",tooltip:\"Link\",showAsMenu: true,\r\n\t\t\t\t\t\t\t\t\t\t\t\t  checkDisability: function(toolBarKey,toolBarItem,item,itemKey,isDefaultDisabled)\r\n\t\t\t\t\t\t\t\t\t\t\t\t  {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t  if(itemKey === \"viewSourceCode\")\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t  {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  return true;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t  }\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t  return false;\r\n\t\t\t\t\t\t\t\t\t\t\t\t  },\r\n\t\t\t\t\t\t\t\t\t\t\t\t  click:function(item,key,event)\r\n\t\t\t\t\t\t\t\t\t\t\t\t  {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t  self.selection.saveSelection();\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t  self.__createElements();\r\n\t\t\t\t\t\t\t\t\t\t\t\t  }};\r\n\t\t};\r\n\t\t\r\n\t\tthis.initialize = function()\r\n\t\t{\r\n\t\t\tthis.__id = this.__nsEditor.getID() + this.name;\r\n\t\t};\r\n\t\t\r\n\t\tthis.componentsInitialized = function()\r\n\t\t{\r\n\t\t\t\r\n\t\t};\r\n\t\t\r\n\t\tthis.resized = function(event)\r\n\t\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\t\r\n\t\t};\r\n\t\t\r\n\t\tthis.__createElements = function()\r\n\t\t{\r\n\t\t\tif(!this.__modal)\r\n\t\t\t{\r\n\t\t\t\tvar setting = {title: \"Add Link\",contentCSSClass:\"nsEditorLinkModalContent\",enableReset: false,contentCallback: this.__getBody.bind(this),footerCallback: this.__getFooter.bind(this)}\r\n\t\t\t\tthis.__modal = this.__nsEditor.__getUtilInstance(\"modal\",\"linkModal\",this.name,this,setting);\r\n\t\t\t}\r\n\t\t\tthis.__modal.toggle();\r\n\t\t};\r\n\t\t\r\n\t\tthis.__getBody = function(objModal,objLink)\r\n\t\t{\r\n\t\t\tif(!this.__divBody)\r\n\t\t\t{\r\n\t\t\t\tthis.__divBody = this.util.createDiv(this.__id + \"LinkModalContentContainer\",\"nsEditorLinkModalContentContainer\");\r\n\t\t\t\tvar html = '<div class=\"nsEditorLinkModalContentForm\">' +\r\n\t\t                        '<label class=\"nsEditorLinkModalContentFormLabel\">URL</label>' +\r\n\t\t                        '<input id=\"##id##TxtUrl\" class=\"nsEditorLinkModalContentFormTextBox\" type=\"text\" />' +\r\n\t\t                    '</div>' +\r\n\t\t                    '<div class=\"nsEditorLinkModalContentForm\">' +\r\n\t\t                        '<label class=\"nsEditorLinkModalContentFormLabel\">Text to display</label>' +\r\n\t\t                    \t'<input id=\"##id##TxtText\" class=\"nsEditorLinkModalContentFormTextBox\" type=\"text\" />' +\r\n\t\t                    '</div>' +\r\n\t\t                    '<div class=\"nsEditorLinkModalContentFormLast\">' +\r\n\t\t                        '<label class=\"nsEditorLinkModalContentFormLabel\">' +\r\n\t\t                    \t\t'<input id=\"##id##ChkNewWindow\" type=\"checkbox\" class=\"nsEditorLinkModalContentFormCheckbox\" checked />&nbsp; Open in new tab or window' + \r\n\t\t                    \t\t'</label>' +\r\n\t\t                    '</div>';\r\n\t\t\t\thtml = html.replaceAll(\"##id##\",this.__id);\r\n\t\t\t\tthis.__divBody.innerHTML = html;\r\n\t\t\t}\r\n\t        return this.__divBody;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__getFooter = function(objModal,objLink)\r\n\t\t{\r\n\t\t\tif(!this.__divFooter)\r\n\t\t\t{\r\n\t\t\t\tthis.__divFooter = this.util.createDiv(null,\"nsEditorLinkFooterContainer\");\r\n\t\t\t\tthis.__divFooter.innerHTML = \"<button class=\\\"nsEditorPrimaryButton nsEditorLinkFooterButton\\\" title=\\\"Submit\\\"><span>Submit</span></button>\";\r\n\t\t\t\tvar btnSubmit = this.__divFooter.querySelector(\".nsEditorLinkFooterButton\");\r\n\t\t\t\tthis.util.addEvent(btnSubmit,\"click\",this.__submitHandler.bind(this));\r\n\t\t\t}\r\n\t\t\treturn this.__divFooter;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__submitHandler = function(event)\r\n\t\t{\r\n\t\t\tthis.editorUtil.stopEvent(event);\r\n\t\t\tvar txtUrl = this.__divBody.querySelector(\"#\" + this.__id + \"TxtUrl\");\r\n\t\t\tvar txtText = this.__divBody.querySelector(\"#\" + this.__id + \"TxtText\");\r\n\t\t\tvar chkNewWindow = this.__divBody.querySelector(\"#\" + this.__id + \"ChkNewWindow\");\r\n\t\t\tif(txtUrl.value && txtUrl.value.trim().length)\r\n\t\t\t{\r\n\t\t\t\tvar url = this.__getLink(txtUrl.value.trim(),this.__config.protocol);\r\n\t\t\t\tvar anchor = this.util.createElement(\"a\");\r\n\t\t\t\tanchor.href = url;\r\n\t\t\t\tanchor.textContent = (txtText.value.trim().length) ? txtText.value.trim() : txtUrl.value.trim();\r\n\t\t\t\tanchor.target = (chkNewWindow.checked ? \"_blank\" : \"\");\r\n\t\t\t\tthis.__insertLink(anchor);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__getLink = function(value,protocol)\r\n\t\t{\r\n\t        value = value.trim();\r\n\t        var url = !value ? \"\" : (protocol && value.indexOf('://') === -1 && value.indexOf('#') !== 0) ? protocol + value : value.indexOf('://') === -1 ? '/' + value : value;\r\n\t        return url;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__insertLink = function(link)\r\n\t\t{\r\n\t\t\tvar arrEvents = [{name:\"closeAllPopups\"}];\r\n\t\t\tvar config = {insertAfterSelectedNode: false,dispatchEvents: arrEvents};\r\n\t\t\tthis.__nsEditor.__addElement(link,config);\r\n\t\t};\r\n\t};\r\n\t\r\n\tNSEditor.prototype.registerPlugin(\"link\",NSEditorLink);\r\n\t\r\n\treturn NSEditorLink;\r\n})();\r\nnsModuleExport(this,\"NSEditorLink\",NSEditorLink);var NSEditorTable = (function()\r\n{\r\n\tvar NSEditorTable = function(nsEditor)\r\n\t{\r\n\t\tthis.__nsEditor = nsEditor;\r\n\t\tthis.util = nsEditor.util;\r\n\t\tthis.editorUtil = nsEditor.editorUtil;\r\n\t\t\r\n\t\tthis.__nsTablePicker = null;\r\n\t\t\r\n\t\tthis.setSettings = function()\r\n\t\t{\r\n\t\t\tvar self = this;\r\n\t\t\tthis.__nsEditor.__toolBarButton[\"table\"] = {html:\"<i class='ns-icon ns-editor-table' aria-hidden='true'></i>\",tooltip:\"Table\",showAsMenu: true,\r\n\t\t\t\t\t\t\t\t\t\t\t\t  checkDisability: function(toolBarKey,toolBarItem,item,itemKey,isDefaultDisabled)\r\n\t\t\t\t\t\t\t\t\t\t\t\t  {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t  if(itemKey === \"viewSourceCode\")\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t  {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  return true;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t  }\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t  return false;\r\n\t\t\t\t\t\t\t\t\t\t\t\t  },\r\n\t\t\t\t\t\t\t\t\t\t\t\t  click:function(item,key,event)\r\n\t\t\t\t\t\t\t\t\t\t\t\t  {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t  self.selection.saveSelection();\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t  self.toggle.call(self,event);\r\n\t\t\t\t\t\t\t\t\t\t\t\t  }};\r\n\t\t};\r\n\t\t\r\n\t\tthis.initialize = function()\r\n\t\t{\r\n\t\t\tthis.__initializeTablePicker();\r\n\t\t};\r\n\t\t\r\n\t\tthis.componentsInitialized = function()\r\n\t\t{\r\n\t\t\t\r\n\t\t};\r\n\t\t\r\n\t\tthis.resized = function(event)\r\n\t\t{\r\n\t\t\t\r\n\t\t};\r\n\t\t\r\n\t\tthis.addStyleInIFrame = function()\r\n\t\t{\r\n\t\t\tvar style = \".nsEditorBody table\\r\\n\" + \r\n\t\t\t\t\t\"{\\r\\n\" + \r\n\t\t\t\t\t\"    border-collapse: collapse;\\r\\n\" + \r\n\t\t\t\t\t\"    margin-bottom: 10px;\\r\\n\" + \r\n\t\t\t\t\t\"    width:100%;\\r\\n\" + \r\n\t\t\t\t\t\"}\\r\\n\" + \r\n\t\t\t\t\t\"\\r\\n\" + \r\n\t\t\t\t\t\".nsEditorBody table tr \\r\\n\" + \r\n\t\t\t\t\t\"{\\r\\n\" + \r\n\t\t\t\t\t\"    user-select: none;\\r\\n\" + \r\n\t\t\t\t\t\"}\\r\\n\" + \r\n\t\t\t\t\t\"\\r\\n\" + \r\n\t\t\t\t\t\".nsEditorBody table tr td,\\r\\n\" + \r\n\t\t\t\t\t\".nsEditorBody table tr th\\r\\n\" + \r\n\t\t\t\t\t\"{\\r\\n\" + \r\n\t\t\t\t\t\"    border: 1px solid #ddd;\\r\\n\" + \r\n\t\t\t\t\t\"    vertical-align: middle;\\r\\n\" + \r\n\t\t\t\t\t\"    user-select: text;\\r\\n\" + \r\n\t\t\t\t\t\"    padding: 5px 10px;\\r\\n\" + \r\n\t\t\t\t\t\"}\\r\\n\" + \r\n\t\t\t\t\t\"\\r\\n\" + \r\n\t\t\t\t\t\".nsEditorBody table .nsEditorHiddenRow\\r\\n\" + \r\n\t\t\t\t\t\"{\\r\\n\" + \r\n\t\t\t\t\t\"\theight: 0px;\\r\\n\" + \r\n\t\t\t\t\t\"    overflow: hidden;\\r\\n\" + \r\n\t\t\t\t\t\"    line-height: 0;\\r\\n\" + \r\n\t\t\t\t\t\"}\\r\\n\" + \r\n\t\t\t\t\t\"\\r\\n\" + \r\n\t\t\t\t\t\".nsEditorBody table .nsEditorHiddenRow td\\r\\n\" + \r\n\t\t\t\t\t\"{\\r\\n\" + \r\n\t\t\t\t\t\"\theight: 0;\\r\\n\" + \r\n\t\t\t\t\t\"    padding: 0;\\r\\n\" + \r\n\t\t\t\t\t\"    border-top: 0;\\r\\n\" + \r\n\t\t\t\t\t\"    overflow: hidden;\\r\\n\" + \r\n\t\t\t\t\t\"    line-height: 0;\\r\\n\" + \r\n\t\t\t\t\t\"}\";\r\n\t\t\treturn style;\r\n\t\t};\r\n\t\t\r\n\t\tthis.destroy = function()\r\n\t\t{\r\n\t\t\tif(this.__nsTablePicker)\r\n\t\t\t{\r\n\t\t\t\tthis.__nsTablePicker.remove();\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.toggle = function(event)\r\n\t\t{\r\n\t\t\tif(this.__nsTablePicker)\r\n\t\t\t{\r\n\t\t\t\tif(this.__nsTablePicker.isOpen())\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__nsTablePicker.close(event);\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.__nsTablePicker.open(event);\r\n\t\t\t\t\tevent.stopPropagation();\r\n\t\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.__tablePickerCellClick = function(event,cell,rowIndex,cellIndex)\r\n\t\t{\r\n\t\t\tthis.__nsTablePicker.close(event);\r\n\t\t\tconsole.log(rowIndex,cellIndex);\r\n\t\t\tthis.__createTable(rowIndex,cellIndex);\r\n\t\t};\r\n\t\t\r\n\t\tthis.__getDefaultValues = function()\r\n\t\t{\r\n\t\t\tvar borderMap = {thin: \"0px\",medium: \"1px\",thick: \"2px\"};\r\n\t\t\tvar doc = this.__nsEditor.__getDocument();\r\n\t\t\tvar textArea = this.__nsEditor.__getTextArea();\r\n\t\t\tvar table = this.util.createElement(\"table\",null,null,doc);\r\n\t\t    table.insertRow(0).insertCell(0).innerHTML = \"xxx\";\r\n\t\t    textArea.appendChild(table);\r\n\t\t    var td = table.getElementsByTagName(\"td\")[0];\r\n\t\t    var tmpValue = this.util.getStyleValue(table, \"border-left-width\");\r\n\t\t    var tableBorder = parseInt(borderMap[tmpValue] || tmpValue, 10);\r\n\t\t    tmpValue = this.util.getStyleValue(td, \"padding-left\");\r\n\t\t    var cellPadding = parseInt(borderMap[tmpValue] || tmpValue, 10);\r\n\t\t    tmpValue = this.util.getStyleValue(td, \"border-left-width\");\r\n\t\t    cellBorder = parseInt(borderMap[tmpValue] || tmpValue, 10);\r\n\t\t    textArea.removeChild(table);\r\n\t\t    return {\r\n\t\t        tableBorder: tableBorder,\r\n\t\t        cellPadding: cellPadding,\r\n\t\t        cellBorder: cellBorder\r\n\t\t    };\r\n\t\t};\r\n\t\t\r\n\t\tthis.__getCellWidth = function(colCount)\r\n\t\t{\r\n\t\t\tvar textArea = this.__nsEditor.__getTextArea();\r\n            var doc = this.__nsEditor.__getDocument();\r\n            var parent = textArea;\r\n\t\t\tvar selection = this.selection.getSelection();\r\n\t\t\tvar self = this;\r\n\t\t\tif(selection && selection.rangeCount)\r\n\t\t\t{\r\n\t\t\t\tvar scanParent = function(paramElement)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn paramElement === textArea || (paramElement && self.editorUtil.isBlock(paramElement,textArea));\r\n\t\t\t\t};\r\n\t\t\t\tvar range = selection.getRangeAt(0);\r\n\t\t\t\tvar startElement = range.startContainer;\r\n\t\t\t\tvar blockElement = this.util.findParentByCallback(startElement,scanParent,textArea);\r\n\t\t\t\tif(blockElement)\r\n\t\t\t\t{\r\n\t\t\t\t\tparent = blockElement;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tvar objDefault = this.__getDefaultValues();\r\n\t\t\tvar tableWidth = parent.offsetWidth;\r\n\t\t\tvar extraWidth = (objDefault.cellPadding * 2) - objDefault.cellBorder;\r\n\t\t\tvar cellWidth = Math.floor((tableWidth / colCount) - extraWidth);\r\n\t\t\treturn cellWidth;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__createTable = function(rowCount,colCount)\r\n\t\t{\r\n\t\t\tvar textArea = this.__nsEditor.__getTextArea();\r\n            var doc = this.__nsEditor.__getDocument();\r\n\t\t\tvar table = this.util.createElement(\"table\",null,null,doc);\r\n\t\t\tvar thead = this.util.createElement(\"thead\",null,null,doc);\r\n\t\t\ttable.appendChild(thead);\r\n\t\t\tvar tbody = this.util.createElement(\"tbody\",null,null,doc);\r\n\t\t\ttable.appendChild(tbody);\r\n\t\t\tthis.__createFirstRow(doc,table,thead,colCount);\r\n            var firstCell = null;\r\n            var tr = null;\r\n            for (var rowIndex = 1; rowIndex <= rowCount; rowIndex++) \r\n            {\r\n                tr = this.__createRow(doc,rowIndex,colCount);\r\n                if (!firstCell) \r\n                {\r\n                \tfirstCell = tr.children[0];\r\n                }\r\n                tbody.appendChild(doc.createTextNode(\"\\n\"));\r\n                tbody.appendChild(tr);\r\n            }\r\n            this.__insertTable(doc,textArea,table,firstCell);\r\n\t\t};\r\n\t\t\r\n\t\tthis.__createFirstRow = function(doc,table,thead,colCount)\r\n\t\t{\r\n\t\t\tvar cellWidth = this.__getCellWidth(colCount);\r\n\t\t\tvar tr = this.util.createElement(\"tr\",null,null,doc);\r\n            this.util.addStyleClass(tr,\"nsEditorHiddenRow\");\r\n            var td = null;\r\n            for (var cellIndex = 1; cellIndex <= colCount; cellIndex++) \r\n            {\r\n                td = this.util.createElement(\"td\",null,null,doc);\r\n                td.style.width = cellWidth + \"px\";\r\n                tr.appendChild(td);\r\n            }\r\n            thead.appendChild(tr);\r\n\t\t};\r\n\t\t\r\n\t\tthis.__createRow = function(doc,rowIndex,colCount)\r\n\t\t{\r\n\t\t\tvar tr = this.util.createElement(\"tr\",null,null,doc);\r\n\t\t\ttr.setAttribute(\"data-ns-row-index\",rowIndex);\r\n            for (var cellIndex = 1; cellIndex <= colCount; cellIndex++) \r\n            {\r\n            \tvar td = this.__createCell(doc,\"td\",rowIndex,cellIndex);\r\n                tr.appendChild(doc.createTextNode(\"\\n\"));\r\n                tr.appendChild(doc.createTextNode(\"\\t\"));\r\n                tr.appendChild(td);\r\n            }\r\n            return tr;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__createCell = function(doc,nodeName,rowIndex,cellIndex)\r\n\t\t{\r\n\t\t\tnodeName = nodeName.toLowerCase();\r\n\t\t\tvar node = this.util.createElement(nodeName,null,null,doc);\r\n\t\t\tnode.setAttribute(\"data-ns-row-index\",rowIndex);\r\n\t\t\tnode.setAttribute(\"data-ns-cell-index\",cellIndex);\r\n\t\t\t//this.__nsEditor.__nsToolTipInElement.addToolTip(node,\"\" + cellIndex);\r\n\t\t\tvar div = this.util.createDiv();\r\n\t\t\tdiv.appendChild(this.util.createElement(\"br\",null,null,doc));\r\n\t\t\tnode.appendChild(div);\r\n            return node;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__insertTable = function(doc,textArea,table,firstCell)\r\n\t\t{\r\n\t\t\tvar self = this;\r\n\t\t\tvar item = {table: table};\r\n\t\t\tvar arrEvents = [{name:\"closeAllPopups\"},{name:\"tableAdded\",args:item}];\r\n\t\t\tvar config = {insertAfterSelectedNode: true,insertAfterNodeCallback:function(blockElement){\r\n\t\t\t\treturn (blockElement && !blockElement.nodeName.match(/^TD|TH|TBODY|TABLE|THEADER|TFOOTER$/));\r\n\t\t\t},dispatchEvents: arrEvents,afterInsertCallback: function(){\r\n\t\t\t\tif(firstCell)\r\n\t            {\r\n\t\t\t\t\tself.selection.setCursorIn(firstCell);\r\n\t\t\t\t\tself.util.scrollIntoView(firstCell,textArea,doc);\r\n\t            }\r\n\t\t\t}};\r\n\t\t\tthis.__nsEditor.__addElement(table,config);\r\n\t\t};\r\n\t\t\r\n\t\tthis.__initializeTablePicker = function()\r\n\t\t{\r\n\t\t\tif(!this.__nsTablePicker)\r\n\t\t\t{\r\n\t\t\t\tvar setting = {isPopUp: true,width: 145, height:130,cellWidth: 12,cellHeight: 11, rowCount: 12,columnCount: 12, cellClickCallback: this.__tablePickerCellClick.bind(this)  };\r\n\t\t\t\tthis.__nsTablePicker = new NSTablePicker(setting);\r\n\t\t\t}\r\n\t\t};\r\n\t};\r\n\t\r\n\tNSEditorTable.setIndexInTable = function(table)\r\n\t{\r\n\t\tvar util = new NSUtil();\r\n\t\tvar arrRow = table.rows;\r\n\t\tfor(var rowIndex = 0;rowIndex < arrRow.length;rowIndex++)\r\n\t\t{\r\n\t\t\tvar row = arrRow[rowIndex];\r\n\t\t\tif(!util.hasStyleClass(row,\"nsEditorHiddenRow\"))\r\n\t\t\t{\r\n\t\t\t\trow.setAttribute(\"data-ns-row-index\",rowIndex);\r\n\t\t\t\tvar arrCell = row.cells;\r\n\t\t\t\tfor(var cellIndex = 0;cellIndex < arrCell.length;cellIndex++)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar cell = arrCell[cellIndex];\r\n\t\t\t\t\tcell.setAttribute(\"data-ns-row-index\",rowIndex);\r\n\t\t\t\t\tcell.setAttribute(\"data-ns-cell-index\",cellIndex);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\t\r\n\tNSEditor.prototype.registerPlugin(\"table\",NSEditorTable);\r\n\t\r\n\treturn NSEditorTable;\r\n})();\r\nnsModuleExport(this,\"NSEditorTable\",NSEditorTable);var NSFooterComp = (function()\r\n{\r\n\tvar NSFooterComp = function(nsEditor)\r\n\t{\r\n\t\tthis.__nsEditor = nsEditor;\r\n\t\tthis.util = nsEditor.util;\r\n\t\tthis.editorUtil = nsEditor.editorUtil;\r\n\t\t\r\n\t\tthis.__compElementPathContainerContainer = null;\r\n\t\tthis.__compElementPath = null;\r\n\t\tthis.__compWords = null;\r\n\t\tthis.__compChars = null;\r\n\t\t\r\n\t\tthis.__excludeSpace = true;\r\n\t\t\r\n\t\tthis.setSettings = function()\r\n\t\t{\r\n\t\t\tthis.__nsEditor.__config[\"enableElementPath\"] = this.util.isUndefinedOrNull(this.__nsEditor.__setting[\"enableElementPath\"]) ? true : Boolean.parse(this.__nsEditor.__setting[\"enableElementPath\"]);\r\n\t\t\tthis.__nsEditor.__config[\"enableWordsCount\"] = this.util.isUndefinedOrNull(this.__nsEditor.__setting[\"enableWordsCount\"]) ? true : Boolean.parse(this.__nsEditor.__setting[\"enableWordsCount\"]);\r\n\t\t\tthis.__nsEditor.__config[\"enableCharsCount\"] = this.util.isUndefinedOrNull(this.__nsEditor.__setting[\"enableCharsCount\"]) ? true : Boolean.parse(this.__nsEditor.__setting[\"enableCharsCount\"]);\r\n\t\t};\r\n\t\t\r\n\t\tthis.initialize = function()\r\n\t\t{\r\n\t\t};\r\n\t\t\r\n\t\tthis.componentsInitialized = function()\r\n\t\t{\r\n\t\t\tif(this.__nsEditor.__config[\"enableElementPath\"])\r\n\t\t\t{\r\n\t\t\t\tthis.__compElementPathContainer = this.util.createElement(\"div\",null,\"nsEditorElementPathContainer\");\r\n\t\t\t\tthis.__nsEditor.__divFooterLeftContainer.appendChild(this.__compElementPathContainer);\r\n\t\t\t\tthis.__compElementPath = this.util.createElement(\"ul\",null,\"nsEditorElementPath\");\r\n\t\t\t\tthis.__compElementPathContainer.appendChild(this.__compElementPath);\r\n\t\t\t}\r\n\t\t\tif(this.__nsEditor.__config[\"enableWordsCount\"])\r\n\t\t\t{\r\n\t\t\t\tthis.__compWords = this.util.createElement(\"span\",null,\"nsEditorWordsContainer\");\r\n\t\t\t\tthis.__nsEditor.__divFooterRightContainer.appendChild(this.__compWords);\r\n\t\t\t}\r\n\t\t\tif(this.__nsEditor.__config[\"enableCharsCount\"])\r\n\t\t\t{\r\n\t\t\t\tthis.__compChars = this.util.createElement(\"span\",null,\"nsEditorCharsContainer\");\r\n\t\t\t\tthis.__nsEditor.__divFooterRightContainer.appendChild(this.__compChars);\r\n\t\t\t}\r\n\t\t\tthis.__nsEditor.__listenInternalEvent(\"change keyup\",this.__keyEventHandler.bind(this));\r\n\t\t\tthis.__nsEditor.__listenInternalEvent(\"mousedown change keyup click selectionchange selectionstart\",this.__pathChangeHandler.bind(this));\r\n\t\t\tthis.__refreshFooterComp();\r\n\t\t\tthis.__setElementPath();\r\n\t\t};\r\n\t\t\r\n\t\tthis.resized = function(event)\r\n\t\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};\r\n\t\t\r\n\t\tthis.__keyEventHandler = function(event)\r\n\t\t{\r\n\t\t\t//var eventDetail = event.detail;\r\n\t\t\t//var orignalEvent = eventDetail.orignalEvent;\r\n\t\t\tthis.__refreshFooterComp();\r\n\t\t};\r\n\t\t\r\n\t\tthis.__pathChangeHandler = function(event)\r\n\t\t{\r\n\t\t\t//var eventDetail = event.detail;\r\n\t\t\t//var orignalEvent = eventDetail.orignalEvent;\r\n\t\t\tthis.__setElementPath();\r\n\t\t};\r\n\t\t\r\n\t\tthis.__refreshFooterComp = function()\r\n\t\t{\r\n\t\t\tif(this.__compWords)\r\n\t\t\t{\r\n\t\t\t\tthis.__compWords.innerHTML = \"Words: \" + this.__getWordCount();\r\n\t\t\t}\r\n\t\t\tif(this.__compChars)\r\n\t\t\t{\r\n\t\t\t\tthis.__compChars.innerHTML = \"Chars: \" + this.__getCharCount();\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__setElementPath = function()\r\n\t\t{\r\n\t\t\tif(this.__compElementPath)\r\n\t\t\t{\r\n\t\t\t\tvar element = this.selection.getElementUnderCursor();\r\n\t\t\t\tthis.__compElementPath.innerHTML = \"\";\r\n\t\t\t\t//var html = \"\";\r\n\t\t\t\tif(element)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar textArea = this.__nsEditor.__getTextArea();\r\n\t\t\t\t\tvar self = this;\r\n\t\t\t\t\tvar scanParent = function(paramElement)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t if(paramElement && textArea !== paramElement && !self.util.isTextNode(paramElement)) \r\n\t\t\t\t\t\t {\r\n\t\t\t\t\t\t\t var name = paramElement.nodeName.toLowerCase();\r\n\t\t\t\t\t\t\t var path = self.__getXPathByElement(paramElement,textArea).replace(/^\\//, \"\");\r\n\t\t\t\t\t\t\t var li = self.__getLI(paramElement,path,name,\"Select \" + name);\r\n\t\t\t\t\t\t\t if(self.__compElementPath.firstChild)\r\n\t\t\t\t\t\t\t {\r\n\t\t\t\t\t\t\t\t self.__compElementPath.insertBefore(self.__getSeparatorLI(),self.__compElementPath.firstChild);\r\n\t\t\t\t\t\t\t }\r\n\t\t\t\t\t\t\t self.__compElementPath.insertBefore(li,self.__compElementPath.firstChild);\r\n\t\t\t\t\t\t\t //html = name + (html ? \" > \" : \"\") + html;\r\n\t\t\t\t\t\t\t //console.log(html);\r\n\t\t\t\t\t\t }\r\n\t\t\t\t\t};\r\n\t\t\t\t\tthis.util.findParentByCallback(element,scanParent,textArea);\r\n\t\t\t\t}\r\n\t\t\t\t//this.__compElementPathContainer.innerHTML = html ? (\"Path: \" + html) : \"\";\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__getSeparatorLI = function() \r\n\t\t{\r\n\t\t\tvar html = \"<li> > </li>\";\r\n\t\t\tvar li = this.util.getElementFromHtml(html);\r\n            var a = li.firstChild;\r\n            return li;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__getLI = function(bindElement, path, name, title) \r\n\t\t{\r\n\t\t\tvar html = \"<li class=\\\"nsEditorElementPathItem\\\"><a role=\\\"button\\\" data-nseditor-path=\\\"\" + path + \"\\\" href=\\\"javascript:void(0)\\\" title=\\\"\" + title + \"\\\" tabindex=\\\"-1\\\"'>\" + name + \"</a></li>\";\r\n            var li = this.util.getElementFromHtml(html);\r\n            var a = li.firstChild;\r\n            this.util.addEvent(a,\"click\",this.__selectPathHandler.bind(this,bindElement,path,name));\r\n            //this.util.addEvent(a,\"contextmenu\",this.__contextMenuHandler.bind(this,bindElement));\r\n            return li;\r\n        };\r\n        \r\n        this.__getXPathByElement = function(element, textArea)\r\n        {\r\n        \tif (!element || element.nodeType !== 1) \r\n        \t{\r\n                return \"\";\r\n            }\r\n            if (!element.parentNode || textArea === element) \r\n            {\r\n                return \"\";\r\n            }\r\n            if (element.id) \r\n            {\r\n                return \"//*[@id='\" + element.id + \"']\";\r\n            }\r\n            var arrSameElement = [].filter.call(element.parentNode.childNodes, function (node) { return node.nodeName === element.nodeName; });\r\n            var parentPath = this.__getXPathByElement(element.parentNode, textArea);\r\n            var indexString = arrSameElement.length > 1 ? \"[\" + (Array.from(arrSameElement).indexOf(element) + 1) + \"]\": \"\";\r\n            var retString = parentPath + \"/\" +  element.nodeName.toLowerCase() + indexString;\r\n            return retString;\r\n        };\r\n        \r\n        this.__selectPathHandler = function(element,path,name,event)\r\n        {\r\n        \ttry \r\n        \t{\r\n        \t\tvar doc = this.__nsEditor.__getDocument();\r\n        \t\tvar textArea = this.__nsEditor.__getTextArea();\r\n                var pathElements = doc.evaluate(path,textArea, null, XPathResult.ANY_TYPE, null);\r\n                var selectedElement = pathElements.iterateNext();\r\n                if (selectedElement) \r\n                {\r\n                \tthis.selection.selectElement(selectedElement);\r\n                    return;\r\n                }\r\n            }\r\n            catch (error) \r\n            { \r\n            }\r\n            this.selection.selectElement(element);\r\n            return;\r\n        };\r\n\t\t\r\n\t\tthis.__getWordCount = function()\r\n\t\t{\r\n\t\t\tvar wordcount = 0;\r\n\t\t\tvar html = this.__nsEditor.__getHtmlFromTextArea() || \"\";\r\n\t\t\tif(html.replace(/\\s*<[^>]*?>\\s*/g, '') !== '') \r\n\t\t\t{\r\n\t            if (html.trim() !== \"\") \r\n\t            {\r\n\t            \t//remove inline tags without adding spaces\r\n\t            \thtml = html.replace(/<\\/?(b|i|em|strong|span|u|strikethrough|a|img|small|sub|sup|label)( [^>*?])?>/gi, '');\r\n\t            \t//replace adjacent tags with possible space between with a space\r\n\t            \thtml = html.replace(/(<[^>]*?>\\s*<[^>]*?>)/ig, ' ');\r\n\t            \t//remove any singular tags\r\n\t                html = html.replace(/(<[^>]*?>)/ig, '');\r\n\t                //condense spacing\r\n\t                html = html.replace(/\\s+/ig, ' ');\r\n\t                //count remaining non-space strings\r\n\t                wordcount = html.match(/\\S+/g).length; \r\n\t            }\r\n\t        }\r\n\t\t\treturn wordcount;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__getCharCount = function()\r\n\t\t{\r\n\t\t\tvar text = this.__nsEditor.__getTextFromTextArea() || \"\";\r\n\t\t\ttext = text.replace(/(\\r\\n|\\n|\\r)/gm,\"\").replace(/^\\s+/g,' ').replace(/\\s+$/g, ' ');\r\n\t\t\ttext = this.__excludeSpace ? text.replace(this.editorUtil.SPACE_REG_EXP, \"\") : text;\r\n\t\t\tvar charcount = text.length;\r\n\t\t\treturn charcount;\r\n\t\t};\r\n\t\t\r\n\t\tNSEditor.prototype.getWordCount = function()\r\n\t\t{\r\n\t\t\tvar objFooterComp = this.__pluginsInstances[\"footercomp\"].instance;\r\n\t\t\treturn objFooterComp.__getWordCount();\r\n\t\t};\r\n\t\t\r\n\t\tNSEditor.prototype.getCharCount = function()\r\n\t\t{\r\n\t\t\tvar objFooterComp = this.__pluginsInstances[\"footercomp\"].instance;\r\n\t\t\treturn objFooterComp.__getCharCount();\r\n\t\t};\r\n\t\t\r\n\t};\r\n\t\r\n\tNSEditor.prototype.registerPlugin(\"footercomp\",NSFooterComp);\r\n\t\r\n\treturn NSFooterComp;\r\n})();\r\nnsModuleExport(this,\"NSFooterComp\",NSFooterComp);  var NSElementResizer = (function()\r\n{\r\n\tvar NSElementResizer = function(nsEditor)\r\n\t{\r\n\t\tthis.__nsEditor = nsEditor;\r\n\t\tthis.util = nsEditor.util;\r\n\t\tthis.editorUtil = nsEditor.editorUtil;\r\n\t\tthis.__config = {};\r\n\t\t\r\n\t\tthis.__container = null;\r\n\t\tthis.__compTopLeft = null;\r\n\t\tthis.__compTopRight = null;\r\n\t\tthis.__compBottomLeft = null;\r\n\t\tthis.__compBottomRight = null;\r\n\t\tthis.__compSize = null;\r\n\t\tthis.__doc = null;\r\n\t\tthis.__win = null;\r\n\t\tthis.__textArea = null;\r\n\t\t\r\n\t\tthis.__isElementResized = false;\r\n        this.__isShown = false;\r\n        this.__element = null;\r\n        this.__objResizer = {};\r\n        this.__resizerRef = null;\r\n\t\t\r\n\t\t\r\n\t\tthis.setSettings = function()\r\n\t\t{\r\n\t\t\tvar setting = this.__nsEditor.__setting.elementResizer;\r\n\t\t\tif(!setting)\r\n\t\t\t{\r\n\t\t\t\tsetting = {};\r\n\t\t\t}\r\n\t\t\tthis.__config = {\r\n\t\t\t\t\t\t\t\tresizableElements: setting[\"resizableElements\"] || \"img, iframe\",//\"img, table, iframe\"\r\n\t\t\t\t\t\t\t\tenableShowSize: this.util.isUndefinedOrNull(setting[\"enableShowSize\"]) ? true : Boolean.parse(setting[\"enableShowSize\"]),\r\n\t\t\t\t\t\t\t\thideSizeInterval: setting[\"hideSizeInterval\"] || 1000,\r\n\t\t\t\t\t\t\t\tsizeLabelFunction: setting[\"sizeLabelFunction\"] ? this.util.getFunction(setting[\"sizeLabelFunction\"]) : null,\r\n\t\t\t\t\t\t\t\tminWidth: setting[\"minWidth\"] || 50,\r\n\t\t\t\t\t\t\t\tminHeight: setting[\"minHeight\"] || 50,\r\n\t\t\t\t\t\t    };\r\n\t\t};\r\n\t\t\r\n\t\tthis.initialize = function()\r\n\t\t{\r\n\t\t};\r\n\t\t\r\n\t\tthis.componentsInitialized = function()\r\n\t\t{\r\n\t\t\tthis.__doc = this.__nsEditor.__getDocument();\r\n\t\t\tthis.__win = this.__nsEditor.__getWindow();\r\n\t\t\tthis.__textArea = this.__nsEditor.__getTextArea();\r\n\t\t\tthis.__createComponents();\r\n\t\t\tthis.__nsEditor.__listenInternalEvent(\"change\",this.__changeHandler.bind(this));\r\n\t\t\tthis.__nsEditor.__listenInternalEvent(\"changePlace\",this.__addListeners.bind(this));\r\n\t\t\tthis.__nsEditor.__listenInternalEvent(\"readonly\",this.__readonlyHandler.bind(this));\r\n\t\t\tthis.__nsEditor.__listenInternalEvent(\"hideResizer\",this.__hide.bind(this));\r\n\t\t\tthis.__nsEditor.__listenInternalEvent(\"maximized\",this.__fullScreenHandler);\r\n\t\t\tthis.__addListeners();\r\n\t\t\tthis.__changeHandler();\r\n\t\t};\r\n\t\t\r\n\t\tthis.resized = function(event)\r\n\t\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};\r\n\t\t\r\n\t\tthis.__createComponents = function()\r\n\t\t{\r\n\t\t\tif(!this.__container)\r\n\t\t\t{\r\n\t\t\t\tthis.__container = this.util.createElement(\"div\",null,\"nsElemEditorResizer\",this.__doc);\r\n\t\t\t\tthis.__compTopLeft = this.__createResizer(\"nsEditorResizerTopLeft\");\r\n\t\t\t\tthis.__compTopRight = this.__createResizer(\"nsEditorResizerTopRight\");\r\n\t\t\t\tthis.__compBottomLeft = this.__createResizer(\"nsEditorResizerBottomLeft\");\r\n\t\t\t\tthis.__compBottomRight = this.__createResizer(\"nsEditorResizerBottomRight\");\r\n\t\t\t\tif(this.__config.enableShowSize)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__compSize = this.util.createElement(\"span\",null,\"nsEditorResizerSize\",this.__doc);\r\n\t\t\t\t\tthis.__container.appendChild(this.__compSize);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__createResizer = function(cssClass)\r\n\t\t{\r\n\t\t\tvar comp = this.util.createElement(\"div\",null,\"nsEditorResizerComp \" + cssClass,this.__doc);\r\n\t\t\tthis.util.addEvent(comp,\"mousedown touchstart\",this.__resizeClickHandler.bind(this,comp));\r\n\t\t\tthis.__container.appendChild(comp);\r\n\t\t\treturn comp;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__addListeners = function(event)\r\n\t\t{\r\n\t\t\tthis.__nsEditor.__listenInternalEvent(\"keydown\", this.__keydownHandler.bind(this));\r\n\t\t\tthis.__nsEditor.__listenInternalEvent(\"resize\", this.__updateCompSize.bind(this));\r\n\t\t\tthis.__nsEditor.__listenInternalEvent(\"mouseup keydown touchend\",this.__clickOutsideHandler.bind(this));\r\n\t\t\tthis.util.addEvent([this.__win,this.__textArea],\"scroll\",this.__scrollHandler.bind(this));\r\n\t\t};\r\n\t\t\r\n\t\tthis.__addListenerToElement = function(element,type)\r\n\t\t{\r\n\t\t\tif(element)\r\n\t\t\t{\r\n\t\t\t\tthis.util.addEvent(element,\"click\",this.__elementClickHandler.bind(this,element,type));\r\n\t\t\t\tthis.util.addEvent(element,\"mousedown\",this.__elementMouseDownHandler.bind(this,element,type));\r\n\t\t\t\tthis.util.addEvent(element,\"dragstart\",this.__hide.bind(this));\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__elementClickHandler = function(element,type,event)\r\n\t\t{\r\n\t\t\tif (this.__element !== element || !this.__isShown) \r\n\t\t\t{\r\n\t\t\t\tevent = this.util.getEvent(event);\r\n\t\t\t\tevent.stopImmediatePropagation();\r\n                this.__element = element;\r\n                this.__show();\r\n                if (type == \"img\" && !this.__element.complete)\r\n                {\r\n                \tthis.util.addEvent(this.__element,\"load\",this.__updateCompSize);\r\n                }\r\n            }\r\n\t\t};\r\n\t\t\r\n\t\tthis.__elementMouseDownHandler = function(element,type,event)\r\n\t\t{\r\n\t\t\tif(this.__nsEditor.__browserDetail.isMSIE && type == \"img\")\r\n\t\t\t{\r\n\t\t\t\tevent = this.util.getEvent(event);\r\n\t\t\t\tevent.preventDefault();\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__resizeClickHandler = function(compResier,event)\r\n\t\t{\r\n\t\t\tif (this.__element && this.__element.parentNode) \r\n\t\t\t{\r\n\t\t\t\tevent = this.util.getEvent(event);\r\n\t\t\t\tevent.preventDefault();\r\n\t\t\t\tevent.stopImmediatePropagation();\r\n\t\t\t\tthis.__isElementResized = true;\r\n\t\t\t\tthis.__objResizer.resizer = compResier;\r\n\t\t\t\tthis.__objResizer.width = this.__element.offsetWidth;\r\n\t\t\t\tthis.__objResizer.height = this.__element.offsetHeight;\r\n\t\t\t\tthis.__objResizer.ratio = this.__objResizer.width / this.__objResizer.height;\r\n\t\t\t\tthis.__objResizer.startX = event.clientX;\r\n\t\t\t\tthis.__objResizer.startY = event.clientY;\r\n\t\t\t\tthis.__nsEditor.__dispatchInternalEvent(\"hidePopup\");\r\n\t\t\t\tthis.__resizerRef = this.__resizeHandler.bind(this); \r\n\t\t\t\tthis.__nsEditor.__listenInternalEvent(\"mousemove touchmove\", this.__resizerRef);\r\n\t        }\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthis.__hide();\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__resizeHandler = function(event)\r\n\t\t{\r\n\t\t\t if (this.__isElementResized && this.__element) \r\n\t\t\t {\r\n\t\t\t\t event = this.util.getEvent(event);\r\n\t\t\t\t event = event.orignalEvent;\r\n\t\t\t\t event = this.util.getEvent(event)\r\n\t\t\t\t event.stopImmediatePropagation();\r\n\t\t\t\t var diffX = event.clientX - this.__objResizer.startX;\r\n\t\t\t\t var diffY = event.clientY - this.__objResizer.startY;\r\n\t\t\t\t var cssClass = this.__objResizer.resizer.className;\r\n\t             var newWidth = 0;\r\n\t             var newHeight = 0;\r\n\t             var isLeft = cssClass.match(/Left/);\r\n\t             var isTop = cssClass.match(/Top/);\r\n\t             var leftMul = isLeft ?  -1 : 1;\r\n\t             var topMul = isTop ?  -1 : 1;\r\n\t             var isImage = this.util.isElementOfType(this.__element,\"img\");\r\n\t             if(isImage)\r\n\t             {\r\n\t            \t if (diffX) \r\n\t            \t {\r\n\t            \t\t newWidth = this.__objResizer.width + leftMul * diffX;\r\n\t            \t\t newHeight = Math.round(newWidth / this.__objResizer.ratio);\r\n\t                 }\r\n\t            \t else \r\n\t            \t {\r\n\t            \t\t newHeight = this.__objResizer.height + topMul * diffY;\r\n\t            \t\t newWidth = Math.round(newHeight * this.__objResizer.ratio);\r\n\t                 }\r\n\t            \t var maxWidth = this.util.getInnerWidth(this.__textArea,this.__win);\r\n\t            \t if (newWidth > maxWidth) \r\n\t            \t {\r\n\t            \t\t newWidth = maxWidth;\r\n\t            \t\t newHeight = Math.round(newWidth / this.__objResizer.ratio);\r\n\t            \t }\r\n\t             }\r\n\t             else\r\n\t             {\r\n\t            \t newWidth = this.__objResizer.width + leftMul * diffX;\r\n\t            \t newHeight = this.__objResizer.height + topMul * diffY;\r\n\t             }\r\n\t             if (newWidth > this.__config.minWidth) \r\n\t             {\r\n\t            \t if (newWidth < this.__container.offsetWidth) \r\n\t            \t {\r\n\t            \t\t this.__element.style.width = newWidth + \"px\";\r\n\t                 }\r\n\t                 else \r\n\t                 {\r\n\t                \t this.__element.style.width = \"100%\";\r\n\t                 }\r\n\t             }\r\n\t             if (newHeight > this.__config.minHeight) \r\n\t             {\r\n\t            \t this.__element.style.height = newHeight + \"px\";\r\n\t             }\r\n\t             this.__updateCompSize();\r\n                 this.__updateSizeLabel(this.__element.offsetWidth,this.__element.offsetHeight);\r\n\t\t\t }\r\n\t\t};\r\n\t\t\r\n\t\tthis.__clickOutsideHandler = function(event)\r\n\t\t{\r\n\t\t\t//var eventDetail = event.detail;\r\n\t\t\t//console.log(\"In __clickOutsideHandler \" + eventDetail.orignalEvent.type);\r\n\t\t\tif (this.__isShown) \r\n\t\t\t{\r\n                if (this.__isElementResized) \r\n                {\r\n                \tvar event = this.util.getEvent(event);\r\n                    //_this.jodit.unlock();\r\n                    this.__isElementResized = false;\r\n                    //this.jodit.setEditorValue();\r\n                    event.stopImmediatePropagation();\r\n                    this.__nsEditor.__removeInternalEvent(\"mousemove touchmove\", this.__resizerRef);\r\n                    this.__resizerRef = null;\r\n                }\r\n                else \r\n                {\r\n                    this.__hide();\r\n                }\r\n            }\r\n\t\t};\r\n\t\t\r\n\t\tthis.__changeHandler = function(event)\r\n\t\t{\r\n\t\t\t if(this.__isShown) \r\n\t\t\t {\r\n\t\t\t\t if (!this.__element || !this.__element.parentNode) \r\n\t\t\t\t {\r\n\t\t\t\t\t this.__hide();\r\n\t\t         }\r\n\t\t         else \r\n\t\t         {\r\n\t\t        \t this.__updateCompSize();\r\n\t\t         }\r\n\t\t     }\r\n\t\t\t if(!this.__nsEditor.isRemoved() && !this.__nsEditor.__isSourceMode)\r\n\t\t\t {\r\n\t\t\t\t var arrElements = this.__textArea.querySelectorAll(this.__config.resizableElements);\r\n\t\t\t\t for(var count = 0;count < arrElements.length;count++)\r\n\t\t\t\t {\r\n\t\t\t\t\t var element = arrElements[count];\r\n\t\t\t\t\t var processed = Boolean.parse(element.getAttribute(\"ns-editor-processed\"));\r\n\t\t\t\t\t var type = element.tagName.toLowerCase();\r\n\t\t\t\t\t if(!processed && (type == \"img\" || type == \"table\"))\r\n\t\t\t\t     {\r\n\t\t\t\t\t\t element.setAttribute(\"ns-editor-processed\",true);\r\n\t\t\t\t\t\t this.__addListenerToElement(element,type);\r\n\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.__readonlyHandler = function(event)\r\n\t\t{\r\n\t\t\tvar eventDetail = event.detail;\r\n\t\t\tif(eventDetail && eventDetail.isReadOnly)\r\n\t\t\t{\r\n\t\t\t\tthis.__hide();\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__scrollHandler = function(event)\r\n\t\t{\r\n\t\t\tif (this.__isShown && !this.__isElementResized) \r\n\t\t\t{\r\n                this.__hide();\r\n            }\r\n\t\t};\r\n\t\t\r\n\t\tthis.__keydownHandler = function(event)\r\n\t\t{\r\n\t\t\tevent = this.util.getEvent(event);\r\n\t\t\tvar keyCode = event.which || event.keyCode;\r\n\t\t\tif(this.__isShown && keyCode === this.util.KEYCODE.DELETE && this.__element && !this.util.isElementOfType(this.__element,\"table\")) \r\n\t\t\t{\r\n\t\t\t\tthis.__deleteHandler(event);\r\n\t        }\r\n\t\t};\r\n\t\t\r\n\t\tthis.__fullScreenHandler = function(event)\r\n\t\t{\r\n\t\t\tif(this.__isShown)\r\n\t\t\t{\r\n\t\t\t\tvar zIndex = this.util.getStyleValue(this.__nsEditor.__divOuterContainer,\"z-index\");\r\n\t\t\t\tthis.__container.style.zIndex = zIndex;\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__deleteHandler = function(event)\r\n\t\t{\r\n\t\t\tif(this.__element)\r\n\t\t\t{\r\n\t\t\t\tif(this.__element.parentNode)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__element.parentNode.removeChild(this.__element);\r\n\t\t\t\t}\r\n\t            this.__hide();\r\n\t            event.preventDefault();\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__updateCompSize = function()\r\n\t\t{\r\n\t\t\tif(this.__isShown && !this.__nsEditor.isRemoved())\r\n\t\t\t{\r\n\t\t\t\tif(this.__element && this.__container) \r\n\t\t\t\t{\r\n\t\t\t\t\tvar parent = this.__container.parentNode || this.__doc.documentElement;\r\n\t                var parentPos = this.editorUtil.getOffset(parent,true);\r\n\t                var elementPos = this.editorUtil.getOffset(this.__element,false);\r\n\t                var left = parseInt(this.__container.style.left || \"0\", 10);\r\n\t                var top = parseInt(this.__container.style.top || \"0\", 10);\r\n\t                var width = this.__container.offsetWidth;\r\n\t                var height = this.__container.offsetHeight;\r\n\t                var newTop = elementPos.top - 1 - parentPos.top;\r\n\t                var newLeft = elementPos.left - 1 - parentPos.left;\r\n\t                if (top !== newTop || left !== newLeft || width !== this.__element.offsetWidth || height !== this.__element.offsetHeight) \r\n\t                {\r\n\t                \tvar style = {top: newTop, left: newLeft, width: this.__element.offsetWidth, height: this.__element.offsetHeight};\r\n\t                \t/*console.log(parentPos);\r\n\t                \tconsole.log(elementPos);\r\n\t                \tconsole.log(style);*/\r\n\t                \tthis.util.css(this.__container,style);\r\n\t                \tthis.__nsEditor.__dispatchInternalEvent(\"changesize\");\r\n\t                }\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__updateSizeLabel = function(width,height)\r\n\t\t{\r\n\t\t\tif(this.__compSize)\r\n\t\t\t{\r\n\t\t\t\tif (width < this.__compSize.offsetWidth || height < this.__compSize.offsetHeight) \r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__showHideSizeComp(false);\r\n\t\t\t    }\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__showHideSizeComp(true);\r\n\t\t\t\t\tvar label = width + \" x \" + height;\r\n\t\t\t\t\tif(this.__config.sizeLabelFunction)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlabel = this.__config.sizeLabelFunction(width,height);\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.__compSize.textContent = label\r\n\t\t\t\t\t}\r\n\t\t\t\t\tvar self = this;\r\n\t\t\t\t\tsetTimeout(function(){ \r\n\t\t\t\t\t\tself.__showHideSizeComp.call(self,false); \r\n\t\t\t\t\t}, this.__config.hideSizeInterval);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__show = function()\r\n\t\t{\r\n\t\t\tif(!this.__isShown && this.editorUtil.isEditable())\r\n\t\t\t{\r\n\t\t\t\tthis.__isShown = true;\r\n\t\t\t\tthis.__nsEditor.__divBodyContainer.appendChild(this.__container);\r\n\t\t\t\tthis.__updateCompSize();\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__hide = function()\r\n\t\t{\r\n\t\t\tthis.__isElementResized = false;\r\n\t        this.__isShown = false;\r\n\t        this.__element = null;\r\n\t        if(this.__container.parentNode)\r\n\t        {\r\n\t        \tthis.__container.parentNode.removeChild(this.__container);\r\n\t        }\r\n\t\t};\r\n\t\t\r\n\t\tthis.__showHideSizeComp = function(isShow)\r\n\t\t{\r\n\t\t\tif(this.__compSize)\r\n\t\t\t{\r\n\t\t\t\tthis.__compSize.style.opacity = isShow ? \"1\" : \"0\";\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t};\r\n\t\r\n\tNSEditor.prototype.registerPlugin(\"elementResizer\",NSElementResizer);\r\n\t\r\n\treturn NSElementResizer;\r\n})();\r\nnsModuleExport(this,\"NSElementResizer\",NSElementResizer);var NSTablePluggins = (function()\r\n{\r\n\tvar NSTablePluggins = function(nsEditor)\r\n\t{\r\n\t\t/*this.nsEditor = nsEditor;\r\n\t\tthis.util = nsEditor.util;\r\n\t\tthis.editorUtil = nsEditor.editorUtil;*/\r\n\t\tthis.__tblUtil = null;\r\n\t\t\r\n\t\tthis.__objTables = {};\r\n\t\tthis.__objUIFunc = null;\r\n\t\t\r\n\t\tthis.__processedTableIDAttribute = \"data-ns-editor-table-id\";\r\n\t\t\r\n\t\tthis.__rowSubMenu = [{key:\"above\",label:\"Insert row above\",toolTip:\"Insert row above\"},\r\n\t\t\t\t\t\t\t {key:\"below\",label:\"Insert row below\",toolTip:\"Insert row below\"}];\r\n\r\n\t\tthis.__columnSubMenu = [{key:\"before\",label:\"Insert column before\",toolTip:\"Insert column before\"},\r\n\t\t\t\t\t \t\t\t{key:\"after\",label:\"Insert column after\",toolTip:\"Insert column after\"}];\r\n\t\t\r\n\t\tthis.__cellSubMenu = [{key:\"mergeCells\",label:\"Merge cells\",toolTip:\"Merge cells\"},\r\n\t\t\t\t\t  {key:\"verticalSplit\",label:\"Vertical split\",toolTip:\"Vertical split\"},\r\n\t\t\t\t\t  {key:\"horizontalSplit\",label:\"Horizontal split\",toolTip:\"Horizontal split\"}];\r\n\t\t\r\n\t\tthis.__alignSubMenu = [{key:\"top\",label:\"Top\",toolTip:\"Align Top\"},\r\n\t\t\t\t\t\t  {key:\"middle\",label:\"Middle\",toolTip:\"Align Middle\"},\r\n\t\t\t\t\t\t  {key:\"bottom\",label:\"Bottom\",toolTip:\"Align Bottom\"},\r\n\t\t\t\t\t\t  {key:\"normal\",label:\"Normal\",toolTip:\"Align Normal\"},\r\n\t\t\t\t\t\t  {key:\"left\",label:\"Left\",toolTip:\"Align Left\"},\r\n\t\t\t\t\t\t  {key:\"right\",label:\"Right\",toolTip:\"Align Right\"},\r\n\t\t\t\t\t\t  {key:\"center\",label:\"Center\",toolTip:\"Align Center\"},\r\n\t\t\t\t\t\t  {key:\"justify\",label:\"Justify\",toolTip:\"Align Justify\"}];\r\n\t\t\r\n\t\tthis.__removeSubMenu = [{key:\"table\",label:\"Delete Table\",toolTip:\"Delete Table\"},\r\n\t\t\t\t\t\t\t  {key:\"row\",label:\"Delete Row\",toolTip:\"Delete Row\"},\r\n\t\t\t\t\t\t\t  {key:\"column\",label:\"Delete Column\",toolTip:\"Delete Column\"},\r\n\t\t\t\t\t\t\t  {key:\"cell\",label:\"Empty Cell\",toolTip:\"Empty Cell\"}];\r\n\t\t\r\n\t\tthis.__objMenu = null;\r\n\t\t\r\n\t\tthis.CLASS_SELECTED_CELL = \"nsEditorSelectedCell\";\r\n\t\t\r\n\t\tthis.initialize = function()\r\n\t\t{\r\n\t\t\tthis.__objMenu = { remove: {html: \"<i class=\\\"ns-icon ns-editor-trash\\\" aria-hidden=\\\"true\\\"></i>\",toolTip:\"Remove\",subMenu:this.__removeSubMenu,subMenuClickHandler:this.__removeClickHandler.bind(this)},\r\n\t\t\t\t\t\t\t   row: {html: \"<i class=\\\"ns-icon ns-editor-bars\\\" aria-hidden=\\\"true\\\"></i>\",toolTip:\"Row\",subMenu:this.__rowSubMenu,subMenuClickHandler:this.__rowClickHandler.bind(this)},\r\n\t\t\t\t\t\t\t   column: {html: \"<i class=\\\"ns-icon ns-editor-layout\\\" aria-hidden=\\\"true\\\"></i>\",toolTip:\"Column\",subMenu:this.__columnSubMenu,subMenuClickHandler:this.__columnClickHandler.bind(this)},\r\n\t\t\t\t\t\t\t   cell: {html: \"<i class=\\\"ns-icon ns-editor-square\\\" aria-hidden=\\\"true\\\"></i>\",toolTip:\"Cell\",subMenu:this.__cellSubMenu,subMenuClickHandler:this.__cellClickHandler.bind(this)},\r\n\t\t\t\t\t\t\t   alignment: {html: \"<i class=\\\"ns-icon ns-editor-align-left\\\" aria-hidden=\\\"true\\\"></i>\",toolTip:\"Alignment\",subMenu:this.__alignSubMenu,subMenuClickHandler:this.__alignClickHandler.bind(this)},\r\n\t\t\t\t\t\t\t   header: {html: \"<i class=\\\"ns-icon ns-editor-header\\\" aria-hidden=\\\"true\\\"></i>\",toolTip:\"Table Header\",menuClickHandler:this.__headerClickHandler.bind(this)},\r\n\t\t\t\t\t\t\t };\r\n\t\t};\r\n\t\t\r\n\t\tthis.setSettings = function()\r\n\t\t{\r\n\t\t\tvar tableSetting = this.nsEditor.__setting[\"tableSetting\"];\r\n\t\t\tif(!tableSetting)\r\n\t\t\t{\r\n\t\t\t\ttableSetting = {};\r\n\t\t\t}\r\n\t\t\tvar tableConfig = {};\r\n\t\t\ttableConfig = {\r\n\t\t\t\t\tenableColumnResize : this.util.isUndefinedOrNull(tableSetting[\"enableColumnResize\"]) ? true : Boolean.parse(tableSetting[\"enableColumnResize\"]),\r\n\t\t\t};\r\n\t\t\tthis.nsEditor.__config[\"tableSetting\"] = tableConfig;\r\n\t\t};\r\n\t\t\r\n\t\tthis.componentsInitialized = function()\r\n\t\t{\r\n\t\t\tthis.nsEditor.__listenInternalEvent(\"tableAdded\", this.__initTable.bind(this));\r\n\t\t\tthis.nsEditor.__listenInternalEvent(\"mousedown mouseup\", this.__handleMouseEvents.bind(this));\r\n\t\t\tthis.nsEditor.__listenInternalEvent(\"dblclick click\", this.__handleClickEvents.bind(this));\r\n\t\t\t\r\n\t\t\tthis.__tblUtil = new NSTableUtil(this.nsEditor.__getDocument(),this.nsEditor.__getWindow());\r\n\t\t\tthis.__objUIFunc = this.nsEditor.__getUtilInstance(\"uiFunc\",\"tablePluggins\",this.name,this,null);\r\n\t\t};\r\n\t\t\r\n\t\tthis.resized = function(event)\r\n\t\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\t\r\n\t\t};\r\n\t\t\r\n\t\tthis.getSelectedCells = function(table)\r\n\t\t{\r\n\t\t\tvar arrCells = null;\r\n\t\t\tif(table)\r\n\t\t\t{\r\n\t\t\t\tarrCells = table.querySelectorAll(\".\" + this.CLASS_SELECTED_CELL);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tvar textArea = this.nsEditor.__getTextArea();\r\n\t\t\t\tarrCells = textArea.querySelectorAll(\".\" + this.CLASS_SELECTED_CELL);\r\n\t\t\t}\r\n\t\t\treturn arrCells; \r\n\t\t};\r\n\t\t\r\n\t\tthis.__initTable = function(event)\r\n\t\t{\r\n\t\t\tif(this.editorUtil.isEditable())\r\n\t\t\t{\r\n\t\t\t\tif(event.detail && event.detail.table)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar table = event.detail.table;\r\n\t\t\t\t\tif(!table.hasAttribute(this.__processedTableIDAttribute))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar id = \"compNSEditorTable\" + this.util.getUniqueId();\r\n\t\t\t\t\t\ttable.setAttribute(this.__processedTableIDAttribute,id);\r\n\t\t\t\t\t\tvar resizableTable = this.__createResizableTable(table);\r\n\t\t\t\t\t\tvar popUp = this.__createPopup(table);\r\n\t\t\t\t\t\tthis.__objTables[id] = {table: table,resizableTable: resizableTable,popUp: popUp};\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.__handleMouseEvents = function(event)\r\n\t\t{\r\n\t\t\tvar item = event.detail;\r\n\t\t\tvar element = item.element;\r\n\t\t\tvar parentElement = item.parentElement;\r\n\t\t\tvar orignalEvent = item.orignalEvent;\r\n\t\t\tvar cell = this.editorUtil.isCell(element) ? element : (this.editorUtil.isCell(parentElement) ? parentElement : null);\r\n\t\t\tif(cell)\r\n\t\t\t{\r\n\t\t\t\tvar table = this.util.findParent(cell,\"TABLE\");\r\n\t\t\t\tvar id = table.getAttribute(this.__processedTableIDAttribute);\r\n\t\t\t\tif(id)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar popUp = this.__objTables[id].popUp;\r\n\t\t\t\t\tif(popUp)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tswitch(orignalEvent.type)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tcase \"mousedown\":\r\n\t\t\t\t\t\t\t\tpopUp.hide();\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\tcase \"mouseup\":\r\n\t\t\t\t\t\t\t\tthis.__highlightCell(cell,table);\r\n\t\t\t\t\t\t\t\tthis.selection.saveSelection();\r\n\t\t\t\t\t\t\t\t/*var offset = {left: -40,top: 17}\r\n\t\t\t\t\t\t\t\tpopUp.show(cell,orignalEvent,offset);*/\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\tpopUp.show(cell,orignalEvent);\r\n\t\t\t\t\t\t\tbreak;\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.__handleClickEvents = function(event)\r\n\t\t{\r\n\t\t\t\r\n\t\t};\r\n\t\t\r\n\t\tthis.__clearTableSelectedCells = function(table)\r\n\t\t{\r\n\t\t\tvar arrCells = this.getSelectedCells(table);\r\n\t\t\tfor(var count = 0;count < arrCells.length;count++)\r\n\t\t\t{\r\n\t\t\t\tthis.util.removeStyleClass(arrCells[count],this.CLASS_SELECTED_CELL);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__highlightCell = function(cell,table)\r\n\t\t{\r\n\t\t\tvar textArea = this.nsEditor.__getTextArea();\r\n\t\t\tthis.__clearTableSelectedCells();\r\n\t\t\tif(cell)\r\n\t\t\t{\r\n\t\t\t\tthis.util.addStyleClass(cell,this.CLASS_SELECTED_CELL);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__createResizableTable = function(table)\r\n\t\t{\r\n\t\t\tvar setting = {getRowCallback: this.__getRow.bind(this)};\r\n\t\t\tvar nsResizableTable = new NSResizableTable(table,setting,this.nsEditor.__getDocument());\r\n\t\t\treturn nsResizableTable;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__createPopup = function(table)\r\n\t\t{\r\n\t\t\tvar setting = {title: \"Edit Table\",enableArrow: true,contentCallback: this.__getPopUpBody.bind(this,table)};\r\n\t\t\tvar inlinePopUp = this.nsEditor.__getUtilInstance(\"inlinePopup\",\"tablePopUp\",this.name,this,setting);\r\n\t\t\tthis.util.addEvent(table,\"click\",this.__tblClickHandler.bind(this));\r\n\t\t\treturn inlinePopUp;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__tblClickHandler = function(event)\r\n\t\t{\r\n\t\t\tthis.editorUtil.stopEvent(event);\r\n\t\t};\r\n\t\t\r\n\t\tthis.__getRow = function(table,objResizableTable)\r\n\t\t{\r\n\t\t\tif(table && table.tBodies && table.tBodies.length > 0 && table.tBodies[0].rows && table.tBodies[0].rows.length > 0)\r\n\t\t\t{\r\n\t\t\t\treturn table.tBodies[0].rows[0];\r\n\t\t\t}\r\n\t\t\treturn null;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__getPopUpBody = function(table,container,objPopup,objTablePluggin)\r\n\t\t{\r\n\t\t\tvar index = 0;\r\n\t\t\tfor(var key in this.__objMenu)\r\n\t\t\t{\r\n\t\t\t\tvar item = this.__objMenu[key];\r\n\t\t\t\tvar arrSubMenu = null;\r\n\t\t\t\tif(index % 3 == 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar compSep = objPopup.getHorizontalSeparator();\r\n\t\t\t\t\tcontainer.appendChild(compSep);\r\n\t\t\t\t}\r\n\t\t\t\tif(item.subMenu && item.subMenu.length)\r\n\t\t\t\t{\r\n\t\t\t\t\tarrSubMenu = this.__getSubMenu(table,objPopup,item.subMenu,item,key);\r\n\t\t\t\t}\r\n\t\t\t\tvar menu = this.__createMenuItem(table,objPopup,item.html,item.toolTip,arrSubMenu,item,key);\r\n\t\t\t\tcontainer.appendChild(menu);\r\n\t\t\t\tindex++;\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__createMenuItem = function(table,objPopup,contentHtml,tooltip,subMenu,item,menuName)\r\n\t\t{\r\n\t\t\tvar handler = (subMenu && subMenu.length) ? null : this.__menuClickHandler.bind(this,table,item,null,menuName);\r\n\t\t\tvar menu = objPopup.getMenuItem(null,null,contentHtml,tooltip,subMenu,handler);\r\n\t\t\treturn menu;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__getSubMenu = function(table,objPopup,arrSubMenu,parentItem,parentMenu)\r\n\t\t{\r\n\t\t\tvar arrRet = [];\r\n\t\t\tfor(var count = 0;count < arrSubMenu.length;count++)\r\n\t\t\t{\r\n\t\t\t\tvar item = arrSubMenu[count];\r\n\t\t\t\tvar handler = this.__menuClickHandler.bind(this,table,item,parentItem,parentMenu);\r\n\t\t\t\tvar anchor = objPopup.getSubMenuItem(null,null,item.label,item.toolTip,handler);\r\n\t\t\t\tarrRet.push(anchor);\r\n\t\t\t}\r\n\t\t\treturn arrRet;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__menuClickHandler = function(table,item,parentItem,parentMenuName,event)\r\n\t\t{\r\n\t\t\tvar textArea = this.nsEditor.__getTextArea();\r\n\t\t\tevent = this.util.getEvent(event);\r\n\t\t\tvar self = this;\r\n\t\t\t/*var cell = this.editorUtil.isCell(event.target) ? event.target : this.util.findParentByCallback(event.target,function(node){\r\n\t\t\t\tnode && self.editorUtil.isCell(node);\r\n\t\t\t},textArea);*/\r\n\t\t\tvar arrCells = this.getSelectedCells(table);\r\n\t\t\tif(arrCells && arrCells.length)\r\n\t\t\t{\r\n\t\t\t\tvar cell = arrCells[0];\r\n\t\t\t\tvar row = this.util.findParent(cell,\"TR\");\r\n\t\t\t\tvar rowIndex = row.rowIndex;\r\n\t\t\t\tvar cellIndex = cell.cellIndex;\r\n\t\t\t\tthis.selection.restoreSelection();\r\n\t\t\t\tif(parentItem && parentItem.subMenuClickHandler)\r\n\t\t\t\t{\r\n\t\t\t\t\tparentItem.subMenuClickHandler(arrCells,row,table,cellIndex,rowIndex,item,parentItem,parentMenuName,event);\r\n\t\t\t\t}\r\n\t\t\t\telse if(item && item.menuClickHandler)\r\n\t\t\t\t{\r\n\t\t\t\t\titem.menuClickHandler(arrCells,row,table,cellIndex,rowIndex,item,parentMenuName,event);\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.warning(\"NSEditor\",\"Selected Cell is not found in Editor\");\r\n\t\t\t}\r\n\t\t\t\r\n\t\t};\r\n\t\t\r\n\t\tthis.__rowClickHandler = function(arrCells,row,table,cellIndex,rowIndex,item,parentItem,parentMenuName,event)\r\n\t\t{\r\n\t\t\tvar self = this;\r\n\t\t\tvar callback = function(newCell,newRow,paramTable,colIndex,rowReference,isInsertBelow)\r\n\t\t\t{\r\n\t\t\t\tself.util.removeStyleClass(newCell,self.CLASS_SELECTED_CELL);\r\n\t\t\t};\r\n\t\t\tswitch(item.key)\r\n\t\t\t{\r\n\t\t\t\tcase \"above\":\r\n\t\t\t\t\tthis.__tblUtil.insertRow(table,row,false,callback); \r\n\t\t\t\tbreak;\r\n\t\t\t\tcase \"below\":\r\n\t\t\t\t\tthis.__tblUtil.insertRow(table,row,true,callback);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tthis.__refreshIndexInTable(table);\r\n\t\t};\r\n\t\t\r\n\t\tthis.__columnClickHandler = function(arrCells,row,table,cellIndex,rowIndex,item,parentItem,parentMenuName,event)\r\n\t\t{\r\n\t\t\tvar self = this;\r\n\t\t\tvar callback = function(newCell,paramTable,refIndex,isInsertAfter)\r\n\t\t\t{\r\n\t\t\t\tself.util.removeStyleClass(newCell,self.CLASS_SELECTED_CELL);\r\n\t\t\t};\r\n\t\t\tswitch(item.key)\r\n\t\t\t{\r\n\t\t\t\tcase \"before\":\r\n\t\t\t\t\tthis.__tblUtil.insertColumn(table,cellIndex,false,callback); \r\n\t\t\t\tbreak;\r\n\t\t\t\tcase \"after\":\r\n\t\t\t\t\tthis.__tblUtil.insertColumn(table,cellIndex,true,callback); \r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tthis.__refreshIndexInTable(table);\r\n\t\t};\r\n\t\t\r\n\t\tthis.__cellClickHandler = function(arrCells,row,table,cellIndex,rowIndex,item,parentItem,parentMenuName,event)\r\n\t\t{\r\n\t\t\tswitch(item.key)\r\n\t\t\t{\r\n\t\t\t\tcase \"mergeCells\":\r\n\t\t\t\t\tthis.__tblUtil.mergeSelectedCells(arrCells,table);\r\n\t\t\t\tbreak;\r\n\t\t\t\tcase \"verticalSplit\":\r\n\t\t\t\t\tthis.__tblUtil.splitCellsVertical(arrCells,table);\r\n\t\t\t\tbreak;\r\n\t\t\t\tcase \"horizontalSplit\":\r\n\t\t\t\t\tthis.__tblUtil.splitCellsHorizontal(arrCells,table);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tthis.__clearTableSelectedCells(table);\r\n\t\t\tthis.__refreshIndexInTable(table);\r\n\t\t};\r\n\t\t\r\n\t\tthis.__alignClickHandler = function(arrCells,row,table,cellIndex,rowIndex,item,parentItem,parentMenuName,event)\r\n\t\t{\t\t\t\r\n\t\t\tswitch(item.key)\r\n\t\t\t{\r\n\t\t\t\tcase \"top\":\r\n\t\t\t\tcase \"middle\":\r\n\t\t\t\tcase \"bottom\":\r\n\t\t\t\tcase \"normal\":\r\n\t\t\t\t\tthis.__objUIFunc.setVerticalAlignForNodes(item.key,arrCells);\r\n\t\t\t\tbreak;\r\n\t\t\t\tcase \"left\":\r\n\t\t\t\tcase \"right\":\r\n\t\t\t\tcase \"center\":\r\n\t\t\t\tcase \"justify\":\r\n\t\t\t\t\tthis.__objUIFunc.setHorizontalAlignForNodes(item.key,arrCells);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__removeClickHandler = function(arrCells,row,table,cellIndex,rowIndex,item,parentItem,parentMenuName,event)\r\n\t\t{\r\n\t\t\tswitch(item.key)\r\n\t\t\t{\r\n\t\t\t\tcase \"table\":\r\n\t\t\t\t\tthis.editorUtil.removeNode(table);\r\n\t\t\t\tbreak;\r\n\t\t\t\tcase \"row\":\r\n\t\t\t\t\tthis.__tblUtil.removeRow(table,rowIndex);\r\n\t\t\t\t\tthis.__refreshIndexInTable(table);\r\n\t\t\t\tbreak;\r\n\t\t\t\tcase \"column\":\r\n\t\t\t\t\tthis.__tblUtil.removeColumn(table,cellIndex);\r\n\t\t\t\t\tthis.__refreshIndexInTable(table);\r\n\t\t\t\tbreak;\r\n\t\t\t\tcase \"cell\":\r\n\t\t\t\t\tfor(var cellIndex = 0;cellIndex < arrCells.length;cellIndex++)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar cell = arrCells[cellIndex];\r\n\t\t\t\t\t\tthis.util.removeAllChildren(cell);\r\n\t\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__headerClickHandler = function(arrCells,row,table,cellIndex,rowIndex,item,menuName,event)\r\n\t\t{\r\n\t\t\t\r\n\t\t};\r\n\t\t\r\n\t\tthis.__refreshIndexInTable = function(table)\r\n\t\t{\r\n\t\t\tNSEditorTable.setIndexInTable(table);\r\n\t\t};\r\n\t\t\r\n\t};\r\n\t\r\n\tNSEditor.prototype.registerPlugin(\"tablePluggins\",NSTablePluggins);\r\n\t\r\n\treturn NSTablePluggins;\r\n})();\r\nnsModuleExport(this,\"NSTablePluggins\",NSTablePluggins);var NSEditorSearchReplace = (function()\r\n{\r\n\tvar NSEditorSearchReplace = function(nsEditor)\r\n\t{\r\n\t\tthis.__nsEditor = nsEditor;\r\n\t\tthis.util = nsEditor.util;\r\n\t\tthis.editorUtil = nsEditor.editorUtil;\r\n\t\t\r\n\t\tthis.__refsSearch = {};\r\n\t\tthis.__selSearchElement = null;\r\n\t\t\r\n\t\tthis.setSettings = function()\r\n\t\t{\r\n\t\t\tvar self = this;\r\n\t\t\tthis.__nsEditor.__toolBarButton[\"searchReplace\"] ={html:\"<i class='ns-icon ns-editor-search' aria-hidden='true'></i>\",tooltip:\"Search Or Replace\",showAsMenu: true,\r\n\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\tisDropdown:true,\r\n\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\tdataSource:[{value:\"Search\",html:\"<span>Search</span>\",tooltip:\"Search\",shortKey:\"ctrl+f\",\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t  click:function(item,key,event)\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  self.__searchClickHandler.call(self,event);\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  }},\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  {value:\"Replace\",html:\"<span>Replace</span>\",tooltip:\"Replace\",shortKey:\"ctrl+h\",\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  click:function(item,key,event)\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  self.__replaceClickHandler.call(self,event);\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  }},\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t],\r\n\t\t\t\t\t\t\t\t\t\t   \t\t\t\t\t  checkDisability: function(toolBarKey,toolBarItem,item,itemKey,isDefaultDisabled)\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  if(itemKey === \"viewSourceCode\")\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  return true;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  }\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  return false;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   }\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t};\r\n\t\t};\r\n\t\t\r\n\t\tthis.initialize = function()\r\n\t\t{\r\n\t\t};\r\n\t\t\r\n\t\tthis.componentsInitialized = function()\r\n\t\t{\r\n\t\t\tvar self = this;\r\n\t\t\tthis.__nsEditor.__listenInternalEvent(\"stickyChanged\",this.__applySearchSticky.bind(this));\r\n\t\t\tthis.__nsEditor.__listenInternalEvent(\"keydown mousedown\",function(event){\r\n\t\t\t\tif(self.__isSearchCompVisible()) \r\n\t\t\t\t{\r\n\t\t\t\t\tself.__selSearchElement = self.selection.getElementUnderCursor();\r\n\t\t\t\t\tself.__updateSearchCount();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t};\r\n\t\t\r\n\t\tthis.resized = function(event)\r\n\t\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.__nsTablePicker)\r\n\t\t\t{\r\n\t\t\t\tthis.__nsTablePicker.remove();\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__searchClickHandler = function(event)\r\n\t\t{\r\n\t\t\tthis.__createSearchComponents();\r\n\t\t\tthis.__showSearchComp();\r\n\t\t\tthis.__hideReplaceComp();\r\n\t\t};\r\n\t\t\r\n\t\tthis.__replaceClickHandler = function(event)\r\n\t\t{\r\n\t\t\tthis.__searchClickHandler();\r\n\t\t\tthis.__showReplaceComp();\r\n\t\t};\r\n\t\t\r\n\t\tthis.__createSearchComponents = function()\r\n\t\t{\r\n\t\t\tif(!this.__refsSearch.wrapper || !this.__refsSearch.wrapper.parentNode)\r\n\t\t\t{\r\n\t\t\t\tvar self = this;\r\n\t\t\t\tthis.__setSearchContainer();\r\n\t\t\t\tthis.__nsEditor.__divTextAreaContainer.appendChild(this.__refsSearch.wrapper);\r\n\t\t\t\tthis.util.addEvent(this.__refsSearch.close,\"click\",this.__hideSearchComp.bind(this));\r\n\t\t\t\tvar prevNextClick = this.__prevNextClickHandler.bind(this);\r\n\t\t\t\tthis.util.addEvent([this.__refsSearch.previous,this.__refsSearch.next],\"click\",prevNextClick);\r\n\t\t\t\tthis.util.addEvent(this.__refsSearch.moreoption,\"click\",this.__toggleReplaceComp.bind(this));\r\n\t\t\t\tthis.util.addEvent(this.__refsSearch.replaceButton,\"click\",this.__btnReplaceClickHandler.bind(this));\r\n\t\t\t\tthis.util.addEvent(this.__refsSearch.replaceAllButton,\"click\",this.__btnReplaceAllClickHandler.bind(this));\r\n\t\t\t\tthis.util.addEvent(this.__refsSearch.search,\"keydown\",this.util.debounce(function(event)\r\n\t\t\t\t{\r\n\t\t\t\t\tevent = self.util.getEvent(event);\r\n\t\t\t\t\tswitch (event.key) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcase self.util.KEYCODE.ENTER:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tself.editorUtil.stopEvent(event);\r\n\t\t\t\t\t\t\t/*if (editor.e.fire('searchNext')) {\r\n\t\t\t\t\t\t\t\tthis.close();\r\n\t\t\t\t\t\t\t}*/\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\tdefault:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tself.__updateSearchCount();\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t},10));\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__setSearchContainer = function()\r\n\t\t{\r\n\t\t\tvar html = \"<div data-ns-ref=\\\"wrapper\\\" class=\\\"nsEditorSearchWrapper\\\">\\r\\n\" + \r\n\t\t\t\t\t\"\t <div class=\\\"nsEditorSearchContainer\\\">\\r\\n\" + \r\n\t\t\t\t\t\"\t\t<div class=\\\"nsEditorSearchContent\\\">\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t<div class=\\\"nsEditorSearchInputCountWrapper\\\">\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t<table cellpadding=\\\"0\\\" cellspacing=\\\"0\\\" class=\\\"nsEditorSearchInputCountOuterContainer\\\">\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t\t<tbody>\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t\t\t<tr>\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t\t\t\t<td class=\\\"nsEditorSearchInputContainer\\\">\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t\t\t\t\t<input data-ns-ref=\\\"search\\\" type=\\\"text\\\" spellcheck=\\\"false\\\" class=\\\"nsEditorSearchInput\\\" placeholder=\\\"Find\\\">\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t\t\t\t</td>\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t\t\t\t<td class=\\\"nsEditorSearchCountContainer\\\">\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t\t\t\t\t<span data-ns-ref=\\\"count\\\" class=\\\"nsEditorSearchCount\\\">0 of 0</span>\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t\t\t\t</td>\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t\t\t</tr>\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t\t</tbody>\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t</table>\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t</div>\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t<div class=\\\"nsEditorSearchButtonContainer\\\">\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t<button data-ns-ref=\\\"next\\\" type=\\\"button\\\" tabindex=\\\"-1\\\" class=\\\"nsEditorSearchButton nsEditorSearchButtonNext\\\">\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t\t<span class=\\\"nsEditorSearchButtonIconWrap\\\">\" +\r\n\t\t\t\t\t\"\t\t\t\t\t\t<i class=\\\"ns-icon ns-editor-next\\\" aria-hidden=\\\"true\\\"></i>\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t\t</span>\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t</button>\\r\\n\" +\r\n\t\t\t\t\t\"\t\t\t\t<button data-ns-ref=\\\"previous\\\" type=\\\"button\\\" tabindex=\\\"-1\\\" class=\\\"nsEditorSearchButton nsEditorSearchButtonPrevious\\\">\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t\t<span class=\\\"nsEditorSearchButtonIconWrap\\\">\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t\t\t<i class=\\\"ns-icon ns-editor-prev\\\" aria-hidden=\\\"true\\\"></i>\\r\\n\" +\r\n\t\t\t\t\t\"\t\t\t\t\t</span>\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t</button>\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t</div>\\r\\n\" +\r\n\t\t\t\t\t\"\t\t\t<div class=\\\"nsEditorSearchButtonContainer\\\">\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t<button data-ns-ref=\\\"moreoption\\\" type=\\\"button\\\" tabindex=\\\"-1\\\" class=\\\"nsEditorSearchButton nsEditorSearchButtonMoreOption\\\">\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t\t<span class=\\\"nsEditorSearchButtonIconWrap\\\">\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t\t\t<i data-ns-ref=\\\"moreoptionicon\\\" class=\\\"ns-icon ns-editor-expand-bold\\\" aria-hidden=\\\"true\\\"></i>\\r\\n\" +\r\n\t\t\t\t\t\"\t\t\t\t\t</span>\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t</button>\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t</div>\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t<div class=\\\"nsEditorSearchButtonContainer\\\">\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t<button data-ns-ref=\\\"close\\\" type=\\\"button\\\" tabindex=\\\"-1\\\" class=\\\"nsEditorSearchButton nsEditorSearchButtonClose\\\">\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t\t<span class=\\\"nsEditorSearchButtonIconWrap\\\">\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t\t\t<i class=\\\"ns-icon ns-editor-close-bold\\\" aria-hidden=\\\"true\\\"></i>\\r\\n\" +\r\n\t\t\t\t\t\"\t\t\t\t\t</span>\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t</button>\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t</div>\\r\\n\" + \r\n\t\t\t\t\t\"\t\t</div>\\r\\n\" + \r\n\t\t\t\t\t\"   \t<div data-ns-ref=\\\"replaceWrapper\\\" class=\\\"nsEditorReplaceContainer\\\">\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t<input data-ns-ref=\\\"replaceInput\\\" class=\\\"nsEditorReplaceInput\\\" placeholder=\\\"Replace\\\" aria-label=\\\"Replace Field\\\">\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t<div class=\\\"nsEditorReplaceButtonWrapper\\\">\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t<span class=\\\"nsEditorReplaceButtonContainer\\\" tabindex=\\\"-1\\\">\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t\t<button data-ns-ref=\\\"replaceButton\\\" class=\\\"nsEditorReplaceButton nsEditorReplaceButtonReplace\\\">Replace</button>\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t</span>\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t<span class=\\\"nsEditorReplaceButtonContainer\\\" tabindex=\\\"-1\\\">\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t\t<button data-ns-ref=\\\"replaceAllButton\\\" class=\\\"nsEditorReplaceButton nsEditorReplaceButtonReplaceAll\\\">Replace All</button>\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t\t</span>\\r\\n\" + \r\n\t\t\t\t\t\"\t\t\t</div>\\r\\n\" + \r\n\t\t\t\t\t\"\t\t</div>\"\r\n\t\t\t\t\t\"\t</div>\\r\\n\" +\r\n\t\t\t\t\t\"</div>\";\r\n\t\t\t\r\n\t\t\tthis.__refsSearch = this.util.getReferenceFromHtml(html).refs;\r\n\t\t\treturn this.__refsSearch.wrapper;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__prevNextClickHandler = function(event)\r\n\t\t{\r\n\t\t\tif(this.__refsSearch.search.value && this.__refsSearch.search.value.trim().length)\r\n\t\t\t{\r\n\t\t\t\tthis.editorUtil.stopEvent(event);\r\n\t\t\t\tvar textArea = this.__nsEditor.__getTextArea();\r\n\t\t\t\tvar searchElement = this.selection.getElementUnderCursor();\r\n\t\t\t\tvar isNext = event.currentTarget == this.__refsSearch.next;\r\n\t\t\t\tthis.__searchTextSelect({startNode: searchElement || textArea.firstChild,text: this.__refsSearch.search.value,next:isNext});\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__btnReplaceClickHandler = function(event)\r\n\t\t{\r\n\t\t\tif(this.__refsSearch.replaceInput.value && this.__refsSearch.replaceInput.value.trim().length && \r\n\t\t\t\t\tthis.__refsSearch.search.value && this.__refsSearch.search.value.trim().length)\r\n\t\t\t{\r\n\t\t\t\tthis.editorUtil.stopEvent(event);\r\n\t\t\t\tvar textArea = this.__nsEditor.__getTextArea();\r\n\t\t\t\tvar searchElement = this.selection.getElementUnderCursor();\r\n\t\t\t\tthis.__searchTextReplace({startNode: searchElement || textArea.firstChild,text: this.__refsSearch.search.value,replaceText:this.__refsSearch.replaceInput.value});\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__btnReplaceAllClickHandler = function(event)\r\n\t\t{\r\n\t\t\tif(this.__refsSearch.replaceInput.value && this.__refsSearch.replaceInput.value.trim().length && \r\n\t\t\t\t\tthis.__refsSearch.search.value && this.__refsSearch.search.value.trim().length)\r\n\t\t\t{\r\n\t\t\t\tthis.editorUtil.stopEvent(event);\r\n\t\t\t\tvar textArea = this.__nsEditor.__getTextArea();\r\n\t\t\t\tvar searchElement = this.selection.getElementUnderCursor();\r\n\t\t\t\tsearchElement = searchElement || textArea.firstChild;\r\n\t\t\t\twhile(this.__searchTextReplace({startNode: searchElement,text: this.__refsSearch.search.value,replaceText:this.__refsSearch.replaceInput.value}))\r\n\t\t\t\t{\r\n\t\t\t\t\tsearchElement = this.selection.getElementUnderCursor();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__showSearchComp = function()\r\n\t\t{\r\n\t\t\tif(!this.__isSearchCompVisible())\r\n\t\t\t{\r\n\t\t\t\tthis.__nsEditor.__dispatchInternalEvent(\"hideAllPopup\",{container: this.__refsSearch.wrapper},{container: this.__refsSearch.wrapper});\r\n\t\t\t\tthis.util.addStyleClass(this.__refsSearch.wrapper,\"nsEditorSearchVisible\");\r\n\t\t\t\tthis.__applySearchSticky();\r\n\t\t\t\tthis.__selSearchElement = this.selection.getElementUnderCursor();\r\n\t\t\t\tvar selectedText = this.selection.getSelection() ? this.selection.getSelection().toString() : \"\";\r\n\t\t\t\tif (selectedText) \r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__refsSearch.search.value = selectedText;\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.__refsSearch.search.value = \"\";\r\n\t\t\t\t}\r\n\t\t\t\tthis.__updateSearchCount();\r\n\t\t\t\tselectedText ? this.__refsSearch.search.select() : this.__refsSearch.search.focus();\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__hideSearchComp = function(event)\r\n\t\t{\r\n\t\t\tthis.util.removeStyleClass(this.__refsSearch.wrapper,\"nsEditorSearchVisible\");\r\n\t\t};\r\n\t\t\r\n\t\tthis.__isSearchCompVisible = function()\r\n\t\t{\r\n\t\t\treturn (this.__refsSearch.wrapper && this.__refsSearch.wrapper.parentNode && this.util.hasStyleClass(this.__refsSearch.wrapper,\"nsEditorSearchVisible\"));\r\n\t\t};\r\n\t\t\r\n\t\tthis.__showReplaceComp = function(event)\r\n\t\t{\r\n\t\t\tif(!this.__isReplaceCompVisible())\r\n\t\t\t{\r\n\t\t\t\tthis.__refsSearch.replaceInput.value = \"\";\r\n\t\t\t\tthis.util.addStyleClass(this.__refsSearch.replaceWrapper,\"nsEditorReplaceContainerVisible\");\r\n\t\t\t\tthis.util.addStyleClass(this.__refsSearch.moreoptionicon,\"ns-editor-collapse-bold\");\r\n\t\t\t\tthis.util.removeStyleClass(this.__refsSearch.moreoptionicon,\"ns-editor-expand-bold\"); \r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__hideReplaceComp = function(event)\r\n\t\t{\r\n\t\t\tthis.util.removeStyleClass(this.__refsSearch.replaceWrapper,\"nsEditorReplaceContainerVisible\");\r\n\t\t\tthis.util.removeStyleClass(this.__refsSearch.moreoptionicon,\"ns-editor-collapse-bold\");\r\n\t\t\tthis.util.addStyleClass(this.__refsSearch.moreoptionicon,\"ns-editor-expand-bold\"); \r\n\t\t};\r\n\t\t\r\n\t\tthis.__toggleReplaceComp = function()\r\n\t\t{\r\n\t\t\treturn this.__isReplaceCompVisible() ? this.__hideReplaceComp() : this.__showReplaceComp();\r\n\t\t};\r\n\t\t\r\n\t\tthis.__isReplaceCompVisible = function()\r\n\t\t{\r\n\t\t\treturn (this.__refsSearch.replaceWrapper && this.__refsSearch.replaceWrapper.parentNode && this.util.hasStyleClass(this.__refsSearch.replaceWrapper,\"nsEditorReplaceContainerVisible\"));\r\n\t\t};\r\n\t\t\r\n\t\t\r\n\t\tthis.__updateSearchCount = function()\r\n\t\t{\r\n\t\t\tif(this.__isSearchCompVisible())\r\n\t\t\t{\r\n\t\t\t\tthis.__refsSearch.search.value.length ? this.util.addStyleClass(this.__refsSearch.count,\"nsEditorSearchCountVisible\") : this.util.removeStyleClass(this.__refsSearch.count,\"nsEditorSearchCountVisible\");\r\n\t\t\t\tvar objCount = this.__getTextCounts(this.__refsSearch.search.value);\r\n\t\t\t\tthis.__refsSearch.count.innerHTML = objCount.index + \"/\" + objCount.count;\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\tthis.__applySearchSticky = function()\r\n\t\t{\r\n\t\t\tvar isSticky = this.__nsEditor.__toolBar.isToolbarSticky();\r\n\t\t\tif(this.__isSearchCompVisible())\r\n\t\t\t{\r\n\t\t\t\tvar css = {};\r\n\t\t\t\tif(isSticky)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.util.addStyleClass(this.__refsSearch.wrapper,\"nsEditorSearchWrapperSticky\");\r\n\t\t\t\t\tvar rect = this.__nsEditor.__toolBar.__divToolBarContainer.getBoundingClientRect();\r\n\t\t\t\t\t//css = {top: rect.top + rect.height,left: rect.left + rect.width};\r\n\t\t\t\t\tcss = {top: rect.top + rect.height,right: rect.left};\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.removeStyleClass(this.__refsSearch.wrapper,\"nsEditorSearchWrapperSticky\");\r\n\t\t\t\t\tcss = {top: \"\",left: \"\",right: \"\"};\r\n\t\t\t\t}\r\n\t\t\t\tthis.util.css(this.__refsSearch.wrapper,css);\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\t//calcCounts\r\n\t\tthis.__getTextCounts = function(text)\r\n\t\t{\r\n\t\t\tvar isInArray = function(paramBound,paramArrBound)\r\n\t\t\t{\r\n\t\t\t\tfor(var count = 0;count < paramArrBound.length;count++)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar tempBound = paramArrBound[count];\r\n\t\t\t\t\tif(tempBound.startContainer == paramBound.startContainer && tempBound.endContainer == paramBound.endContainer &&\r\n\t\t\t\t\t\ttempBound.startOffset == paramBound.startOffset && tempBound.endOffset == paramBound.endOffset)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\treturn false;\r\n\t\t\t};\r\n\t\t\tvar objRet = {index: 0,count: 0};\r\n\t\t\tvar doc = this.__nsEditor.__getDocument();\r\n\t\t\tvar textArea = this.__nsEditor.__getTextArea();\r\n\t\t\tvar range = this.selection.getRange();\r\n\t\t\tvar startNode = textArea.firstChild;\r\n\t\t\tvar arrBound = [];\r\n\t\t\tvar bound = null;\r\n\t\t\twhile(startNode && text.length) \r\n\t\t\t{\r\n\t\t\t\tbound = this.__searchText({startNode: startNode,text: text,next: true,deep: 0,range: (bound || doc.createRange())});\r\n\t\t\t\tif(bound)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (isInArray(bound,arrBound)) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tarrBound.push(bound);\r\n\t\t\t\t\tstartNode = bound.startContainer;\r\n\t\t\t\t\tobjRet.count++;\r\n\t\t\t\t\tif (range && isInArray(range, [bound])) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tobjRet.index = objRet.count;\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\tstartNode = null;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\treturn objRet;\r\n\t\t};\r\n\t\t\r\n\t\t//objParam has properties startNode,text,next,deep,range\r\n\t\t//find\r\n\t\tthis.__searchText = function(objParam)\r\n\t\t{\r\n\t\t\tif (objParam.startNode && objParam.text.length) \r\n\t\t\t{\r\n\t\t\t\tvar textArea = this.__nsEditor.__getTextArea();\r\n\t\t\t\tobjParam.sentence = \"\";\r\n\t\t\t\tobjParam.bound = {startContainer: null,startOffset: null,endContainer: null,endOffset: null};\r\n\t\t\t\tvar siblingProperty = objParam.next ? \"nextSibling\" : \"previousSibling\";\r\n\t\t\t\tvar childProperty = objParam.next ? \"firstChild\" : \"lastChild\";\r\n\t\t\t\tvar self = this;\r\n\t\t\t\tthis.util.findNodeWithCurrent(objParam.startNode,function(node) \r\n\t\t\t\t{\r\n\t\t\t\t\tif(node && self.__isSearchNode.call(self,objParam,node))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t}\r\n\t\t\t\t\treturn false;\r\n\t            },textArea,siblingProperty,childProperty);\r\n\t\t\t\tif (objParam.bound.startContainer && objParam.bound.endContainer) \r\n\t\t\t\t{\r\n\t\t\t\t\treturn objParam.bound;\r\n\t\t\t\t}\r\n\t\t\t\tif (!objParam.deep) \r\n\t\t\t\t{\r\n\t\t\t\t\tthis.__selSearchElement = objParam.next ? textArea.firstChild : textArea.lastChild;\r\n\t\t\t\t\treturn this.__searchText({startNode: this.__selSearchElement,text: objParam.text,next: objParam.next,deep: objParam.deep + 1,range: objParam.range});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\t\t\r\n\t\t//objParam has properties text,next,deep,range,sentence,bound\r\n\t\tthis.__isSearchNode = function(objParam,paramNode)\r\n\t\t{\r\n\t\t\tif (this.util.isTextNode(paramNode) && paramNode.nodeValue != null && paramNode.nodeValue.length)\r\n\t\t\t{\r\n\t\t\t\tvar win = this.__nsEditor.__getWindow();\r\n\t\t\t\tvar value = paramNode.nodeValue;\r\n\t\t\t\tif (!objParam.next && paramNode === objParam.range.startContainer) \r\n\t\t\t\t{\r\n\t\t\t\t\tvalue = !objParam.deep ? value.substr(0, objParam.range.startOffset) : value.substr(objParam.range.endOffset);\r\n\t\t\t\t} \r\n\t\t\t\telse if (objParam.next && paramNode === objParam.range.endContainer) \r\n\t\t\t\t{\r\n\t\t\t\t\tvalue = !objParam.deep ? value.substr(objParam.range.endOffset) : value.substr(0, objParam.range.startOffset);\r\n\t\t\t\t}\r\n\t\t\t\tvar tmpSentence = objParam.next ? objParam.sentence + value : value + objParam.sentence;\r\n\t\t\t\tvar part = this.__searchSomePart(objParam.text,tmpSentence,objParam.next);\r\n\t\t\t\tif(part != false) \r\n\t\t\t\t{\r\n\t\t\t\t\tvar currentPart = this.__searchSomePart(objParam.text,value,objParam.next);\r\n\t\t\t\t\tif (currentPart === true) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcurrentPart = this.editorUtil.trim(objParam.text);\r\n\t\t\t\t\t} \r\n\t\t\t\t\telse if(currentPart === false) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcurrentPart = this.__searchSomePart(value,objParam.text,objParam.next);\r\n\t\t\t\t\t\tif (currentPart === true) \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tcurrentPart = this.editorUtil.trim(value);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tvar currentPartIndex = this.__searchSomePartIndex(objParam.text,value,objParam.next) || 0;\r\n\t\t\t\t\tif(((objParam.next && !objParam.deep) || (!objParam.next && objParam.deep)) && paramNode.nodeValue.length - value.length > 0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcurrentPartIndex += paramNode.nodeValue.length - value.length;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (objParam.bound.startContainer == null) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tobjParam.bound.startContainer = paramNode;\r\n\t\t\t\t\t\tobjParam.bound.startOffset = currentPartIndex;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (part !== true) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tobjParam.sentence = tmpSentence;\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\tobjParam.bound.endContainer = paramNode;\r\n\t\t\t\t\t\tobjParam.bound.endOffset = currentPartIndex;\r\n\t\t\t\t\t\tobjParam.bound.endOffset += currentPart.length;\r\n\t\t\t\t\t\treturn true;\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\tobjParam.sentence = \"\";\r\n\t\t\t\t\tobjParam.bound = {startContainer: null,startOffset: null,endContainer: null,endOffset: null};\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse if (this.editorUtil.isBlock(paramNode,win) && objParam.sentence != \"\") \r\n\t\t\t{\r\n\t\t\t\tobjParam.sentence = objParam.next ? objParam.sentence + \" \" : \" \" + objParam.sentence;\r\n\t\t\t}\r\n\r\n\t\t\treturn false;\r\n\t\t};\r\n\t\t\r\n\t\t//objParam has properties startNode,text,next\r\n\t\t//findAndSelect\r\n\t\tthis.__searchTextSelect = function(objParam)\r\n\t\t{\r\n\t\t\tvar doc = this.__nsEditor.__getDocument();\r\n\t\t\tobjParam.range = this.selection.getRange();\r\n\t\t\tobjParam.deep = 0;\r\n\t\t\tvar bound = this.__searchText(objParam);\r\n\t\t\tif (bound && bound.startContainer && bound.endContainer) \r\n\t\t\t{\r\n\t\t\t\tvar range = doc.createRange();\r\n\t\t\t\ttry \r\n\t\t\t\t{\r\n\t\t\t\t\trange.setStart(bound.startContainer,bound.startOffset);\r\n\t\t\t\t\trange.setEnd(bound.endContainer,bound.endOffset);\r\n\t\t\t\t\tthis.selection.selectRange(range);\r\n\t\t\t\t} \r\n\t\t\t\tcatch (error) \r\n\t\t\t\t{\r\n\t\t\t\t\tconsole.debug(error);\r\n\t\t\t\t}\r\n\t\t\t\tthis.__scrollToNode(bound.startContainer);\r\n\t\t\t\tthis.__selSearchElement = bound.startContainer;\r\n\t\t\t\tthis.__updateSearchCount();\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t\treturn false;\r\n\t\t};\r\n\t\t\r\n\t\t//objParam has properties startNode,text,replaceText\r\n\t\t//findAndReplace\r\n\t\tthis.__searchTextReplace = function(objParam)\r\n\t\t{\r\n\t\t\tvar doc = this.__nsEditor.__getDocument();\r\n\t\t\tobjParam.next = true;\r\n\t\t\tobjParam.range = this.selection.getRange();\r\n\t\t\tobjParam.deep = 0;\r\n\t\t\tvar bound = this.__searchText(objParam);\r\n\t\t\tif (bound && bound.startContainer && bound.endContainer) \r\n\t\t\t{\r\n\t\t\t\tvar range = doc.createRange();\r\n\t\t\t\ttry \r\n\t\t\t\t{\r\n\t\t\t\t\trange.setStart(bound.startContainer,bound.startOffset);\r\n\t\t\t\t\trange.setEnd(bound.endContainer,bound.endOffset);\r\n\t\t\t\t\trange.deleteContents();\r\n\t\t\t\t\tvar textNode = doc.createTextNode(objParam.replaceText);\r\n\t\t\t\t\trange.insertNode(textNode);\r\n\t\t\t\t\tthis.selection.selectElement(textNode);\r\n\t\t\t\t\tthis.__scrollToNode(textNode);\r\n\t\t\t\t} \r\n\t\t\t\tcatch (error) \r\n\t\t\t\t{\r\n\t\t\t\t\tconsole.debug(error);\r\n\t\t\t\t}\r\n\t\t\t\tthis.__updateSearchCount();\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t\treturn false;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__searchSomePart = function(text,sentence,start,getIndex)\r\n\t\t{\r\n\t\t\tstart = this.util.isUndefinedOrNull(start) ? true : Boolean.parse(start);\r\n\t\t\tgetIndex = Boolean.parse(getIndex);\r\n\t\t\ttext = this.editorUtil.trim(text.toLowerCase());\r\n\t\t\tsentence = sentence.toLowerCase();\r\n\r\n\t\t\tvar textIndex = start ? 0 : text.length - 1;\r\n\t\t\tvar length = 0;\r\n\t\t\tvar startAtIndex = null;\r\n\t\t\tvar inc = start ? 1 : -1;\r\n\t\t\tvar tmp = [];\r\n\r\n\t\t\tfor (var count = (start ? 0 : sentence.length - 1); !this.util.isUndefined(sentence[count]);count += inc) \r\n\t\t\t{\r\n\t\t\t\tvar some = (text[textIndex] === sentence[count]);\r\n\t\t\t\tif (some || (startAtIndex != null && this.editorUtil.SPACE_REG_EXP.test(sentence[count]))) \r\n\t\t\t\t{\r\n\t\t\t\t\tif (startAtIndex == null || !start) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tstartAtIndex = count;\r\n\t\t\t\t\t}\r\n\t\t\t\t\ttmp.push(sentence[count]);\r\n\t\t\t\t\tif(some) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlength += 1;\r\n\t\t\t\t\t\ttextIndex += inc;\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\tstartAtIndex = null;\r\n\t\t\t\t\ttmp.length = 0;\r\n\t\t\t\t\tlength = 0;\r\n\t\t\t\t\ttextIndex = start ? 0 : text.length - 1;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (length === text.length) \r\n\t\t\t\t{\r\n\t\t\t\t\treturn getIndex ? startAtIndex : true;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (getIndex) \r\n\t\t\t{\r\n\t            return this.util.isUndefinedOrNull(startAtIndex) ? startAtIndex : false;\r\n\t        }\r\n\t\t\tif(tmp.length) \r\n\t\t\t{\r\n\t\t\t\treturn start ? tmp.join('') : tmp.reverse().join('');\r\n\t\t\t}\r\n\t\t\treturn false;\r\n\t\t};\r\n\t\t\r\n\t\tthis.__searchSomePartIndex = function(text,sentence,start)\r\n\t\t{\r\n\t\t\tstart = this.util.isUndefinedOrNull(start) ? true : Boolean.parse(start);\r\n\t        return this.__searchSomePart(text,sentence,start,true);\r\n\t\t};\r\n\t\t\r\n\t\tthis.__scrollToNode = function(node)\r\n\t\t{\r\n\t\t\tvar textArea = this.__nsEditor.__getTextArea();\r\n\t\t\tvar parent = this.editorUtil.getClosestElement(node,this.util.isElement,textArea);\r\n\t\t\tif (!parent) \r\n\t\t\t{\r\n\t\t\t\tparent = this.util.findPrevNode(node,this.util.isElement,textArea);\r\n\t\t\t}\r\n\t\t\tif(parent && parent != textArea)\r\n\t\t\t{\r\n\t\t\t\tparent.scrollIntoView();\r\n\t\t\t}\r\n\t\t};\r\n\t};\r\n\t\r\n\tNSEditor.prototype.registerPlugin(\"searchReplace\",NSEditorSearchReplace);\r\n\t\r\n\treturn NSEditorSearchReplace;\r\n})();\r\nnsModuleExport(this,\"NSEditorSearchReplace\",NSEditorSearchReplace);";
