From 0493c5b7b0c3a73f0e4d3a81b2d7962d24e1e064 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Sat, 9 Nov 2013 03:22:36 +0000
Subject: [PATCH] Connect the redactor editor to the autolock

Previously the richtext editor introduced the loss of the collision
avoidance feature.
---
 js/redactor-osticket.js | 5 +++++
 scp/js/ticket.js        | 4 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/js/redactor-osticket.js b/js/redactor-osticket.js
index 2efba9ebc..5184d3344 100644
--- a/js/redactor-osticket.js
+++ b/js/redactor-osticket.js
@@ -64,6 +64,11 @@ RedactorPlugins.draft = {
     setupDraftUpdate: function(data) {
         this.$box.parent().find('.draft-saved').show();
 
+        // Slight workaround. Signal the 'keyup' event normally signaled
+        // from typing in the <textarea>
+        if ($.autoLock && this.opts.draft_namespace == 'ticket.response')
+            $.autoLock.handleEvent();
+
         if (typeof data != 'object')
             data = $.parseJSON(data);
 
diff --git a/scp/js/ticket.js b/scp/js/ticket.js
index fb9f7370e..84f7e287f 100644
--- a/scp/js/ticket.js
+++ b/scp/js/ticket.js
@@ -200,6 +200,7 @@ var autoLock = {
             type: 'POST',
             url: 'ajax.php/tickets/'+autoLock.tid+'/lock/'+autoLock.lockId+'/release',
             data: 'delete',
+            async: false,
             cache: false,
             success: function(){
 
@@ -257,7 +258,8 @@ var autoLock = {
         clearTimeout(autoLock.timerId);
         autoLock.timerId=setTimeout(function () { autoLock.monitorEvents() },30000);
     }
-}
+};
+$.autoLock = autoLock;
 
 /*
    UI & form events
-- 
GitLab