[otrs-cvs] FAQ/var/httpd/htdocs/js FAQ.Agent.TicketCompose.js, 1.8, 1.9

"CVS commits notifications of OTRS.org" <[email protected]>
Newsgroups gmane.comp.otrs.cvs
Message-ID <[email protected]>
Comments:
Update of /home/cvs/FAQ/var/httpd/htdocs/js
In directory lancelot:/tmp/cvs-serv11819/var/httpd/htdocs/js

Modified Files:
	FAQ.Agent.TicketCompose.js 
Log Message:
Fixed bug#9116 - CKEditor cursor issue with Chrome browser.

Author: mn

Index: FAQ.Agent.TicketCompose.js
===================================================================
RCS file: /home/cvs/FAQ/var/httpd/htdocs/js/FAQ.Agent.TicketCompose.js,v
retrieving revision 1.8
retrieving revision 1.9
diff -2 -u -d -r1.8 -r1.9
--- FAQ.Agent.TicketCompose.js	12 Mar 2012 06:39:08 -0000	1.8
+++ FAQ.Agent.TicketCompose.js	7 Feb 2013 14:07:58 -0000	1.9
@@ -1,5 +1,5 @@
 // --
 // FAQ.Agent.TicketCompose.js - provides the special module functions for AgentFAQZoom
-// Copyright (C) 2001-2012 OTRS AG, http://otrs.org/\n";
+// Copyright (C) 2001-2013 OTRS AG, http://otrs.org/\n";
 // --
 // $Id$
@@ -60,5 +60,10 @@
         }
 
-        var InstanceName = $Element.attr('id');
+        // See bug#9116:
+        // In Chrome sometimes the click event is triggered before the focus event
+        // we prevent that by checking EditorGotFocus first
+
+        var InstanceName = $Element.attr('id'),
+            EditorGotFocus = false;
         // Register RTE events for saving the cursor position
         if (typeof CKEDITOR !== 'undefined' && CKEDITOR && CKEDITOR.instances.RichText) {
@@ -66,8 +71,12 @@
             CKEDITOR.instances[InstanceName].on('contentDom', function() {
                 CKEDITOR.instances[InstanceName].document.on('click', function () {
-                    $('#' + InstanceName).data('RTECursor', CKEDITOR.instances[InstanceName].getSelection().getRanges());
+                    if (EditorGotFocus) {
+                        $('#' + InstanceName).data('RTECursor', CKEDITOR.instances[InstanceName].getSelection().getRanges());
+                    }
                 });
                 CKEDITOR.instances[InstanceName].document.on('keyup', function () {
-                    $('#' + InstanceName).data('RTECursor', CKEDITOR.instances[InstanceName].getSelection().getRanges());
+                    if (EditorGotFocus) {
+                        $('#' + InstanceName).data('RTECursor', CKEDITOR.instances[InstanceName].getSelection().getRanges());
+                    }
                 });
             });
@@ -78,4 +87,7 @@
                 var RTECursorRange = $('#' + InstanceName).data('RTECursor'),
                     Selection;
+
+                EditorGotFocus = true;
+
                 if (RTECursorRange) {
                     Selection = new CKEDITOR.dom.selection(CKEDITOR.instances[InstanceName].document);
---------------------------------------------------------------------
OTRS mailing list: cvs-log - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/cvs-log
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/cvs-log
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.