Telerik,
I have implemented a version of a character counter I've found on this site.Using tools such as Drip I've found that the javascript leaks memory when using IE. I'm using the Q3 from 2009, and I have access to the latest Telerik library. Would updating it to the newest version help solve some of the problem? Have I implemented the functionality wrong? Do I need to have a cleanup function somewhere in here? I use the character counter on two editors (a short description, and a product description) on the same page. Please let me know if I've done something wrong or if I can implement this function below
both editors have this modules line
Thanks for the help.
I have implemented a version of a character counter I've found on this site.Using tools such as Drip I've found that the javascript leaks memory when using IE. I'm using the Q3 from 2009, and I have access to the latest Telerik library. Would updating it to the newest version help solve some of the problem? Have I implemented the functionality wrong? Do I need to have a cleanup function somewhere in here? I use the character counter on two editors (a short description, and a product description) on the same page. Please let me know if I've done something wrong or if I can implement this function below
| MyModule = function(element) { |
| MyModule.initializeBase(this, [element]); |
| } |
| MyModule.prototype = |
| { |
| initialize: function() { |
| MyModule.callBaseMethod(this, 'initialize'); |
| var selfPointer = this; |
| this.get_editor().add_selectionChange(function() { selfPointer.CountCharAction(); }); |
| this.get_editor().attachEventHandler("onkeyup", function() { selfPointer.CountCharAction(); }); |
| this.get_editor().attachEventHandler("onpaste", function() { selfPointer.CountCharAction(); }); |
| this.get_editor().attachEventHandler("onblur", function() { selfPointer.CountCharAction(); }); |
| this.CountCharAction(); |
| }, |
| //A method that does the actual work - it is usually attached to the "selection changed" editor event |
| CountCharAction: function() { |
| var controlName = this.get_editor(); |
| var element = this.get_element(); |
| var chars = 0; |
| var content; |
| if (controlName.get_id().indexOf("Short") > 0) { |
| content = this.get_editor().get_html(true); |
| if (content) { |
| var punctRegX = /[!\.?;,:&_\-\-\{\}\[\]\(\)~#'"]/g; |
| var trimRegX = /(^\s+)|(\s+$)/g; |
| content = content.replace(punctRegX, ""); |
| content = content.replace(trimRegX, ""); |
| if (content) { |
| chars = content.length; |
| } |
| } |
| if (chars > 55) { |
| element.innerHTML = "<span style='line-height:22px; color:#F90A0A'> Characters: " + chars + " Short Description cannot be over 55 characters</span>"; |
| } |
| else { |
| element.innerHTML = "<span style='line-height:22px'> Characters: " + chars + " </span>"; |
| } |
| } |
| else { |
| content = this.get_editor().get_text(); |
| if (content) { |
| var punctRegX = /[!\.?;,:&_\-\-\{\}\[\]\(\)~#'"]/g; |
| var trimRegX = /(^\s+)|(\s+$)/g; |
| var removeNL = /[\n\r\t]/g; |
| content = content.replace(removeNL, ""); |
| content = content.replace(" ", ""); |
| content = content.split(' ').join(''); |
| content = content.replace(trimRegX, "").replace(trimRegX, ""); |
| chars = content.length; |
| if (chars > 22500) { |
| element.innerHTML = "<span style='line-height:22px; color:#F90A0A'> Characters: " + chars + " Product Description cannot be over 22,500 characters</span>"; |
| } |
| else { |
| element.innerHTML = "<span style='line-height:22px'> Characters: " + chars + " </span>"; |
| } |
| } |
| } |
| } |
| }; |
| MyModule.registerClass('MyModule', Telerik.Web.UI.Editor.Modules.ModuleBase); |
both editors have this modules line
| <Modules> |
| <telerik:EditorModule Name="MyModule" Enabled="true" Visible="true" /> |
| <telerik:EditorModule Name="RadEditorStatistics" Enabled="true" Visible="false" /> |
| </Modules> |
Thanks for the help.
