From d7864093cec0102c15b8e863119810f467cd306d Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Wed, 9 Apr 2014 08:51:50 -0500
Subject: [PATCH] pjax: Fixup sub navigation changes

---
 js/redactor-osticket.js |  1 +
 scp/js/scp.js           | 12 ++++++++++++
 scp/tickets.php         |  3 +--
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/js/redactor-osticket.js b/js/redactor-osticket.js
index 4a919612b..85bed3ac9 100644
--- a/js/redactor-osticket.js
+++ b/js/redactor-osticket.js
@@ -280,4 +280,5 @@ $(function() {
     };
     findRichtextBoxes();
     $(document).ajaxStop(findRichtextBoxes);
+    $(document).on('pjax:success', findRichtextBoxes);
 });
diff --git a/scp/js/scp.js b/scp/js/scp.js
index e2bb171c5..78cefa1e3 100644
--- a/scp/js/scp.js
+++ b/scp/js/scp.js
@@ -623,8 +623,20 @@ getConfig = (function() {
                 dataType: 'json',
                 success: function (json_config) {
                     dfd.resolve(json_config);
+                },
+                error: function() {
+                    requested = null;
                 }
             });
         return dfd;
     }
 })();
+
+$(document).on('pjax:start', function() { clearInterval(window.ticket_refresh); });
+$(document).on('click', 'a', function() {
+    var ul = $(this).closest('ul');
+    if (ul.is('#sub_nav')) {
+        $('a.active', ul).removeClass('active');
+        $(this).addClass('active');
+    }
+});
diff --git a/scp/tickets.php b/scp/tickets.php
index 2df7cc7a2..3699015aa 100644
--- a/scp/tickets.php
+++ b/scp/tickets.php
@@ -617,8 +617,7 @@ if($ticket) {
     //set refresh rate if the user has it configured
     if(!$_POST && !$_REQUEST['a'] && ($min=$thisstaff->getRefreshRate()))
         $ost->addExtraHeader('',
-            "clearInterval(window.ticket_refresh);
-             window.ticket_refresh = setTimeout(function() { $.pjax({url: document.location.href, container:'#content'});},"
+            "window.ticket_refresh = setTimeout(function() { $.pjax({url: document.location.href, container:'#content'});},"
             .($min*60000).");");
 }
 
-- 
GitLab