From 4f1f09e5e4c2e16d557e3051e660c371d6543d4c Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Tue, 17 Mar 2015 14:54:26 -0500
Subject: [PATCH] dashboard: Fix missing Raphael on PJAX load

---
 include/class.nav.php                       |  2 +-
 include/staff/templates/navigation.tmpl.php |  5 ++++-
 scp/js/dashboard.inc.js                     | 16 ++++++++++------
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/include/class.nav.php b/include/class.nav.php
index 1c721b854..2b54c32d6 100644
--- a/include/class.nav.php
+++ b/include/class.nav.php
@@ -113,7 +113,7 @@ class StaffNav {
     function getTabs(){
         if(!$this->tabs) {
             $this->tabs=array();
-            $this->tabs['dashboard'] = array('desc'=>__('Dashboard'),'href'=>'dashboard.php','title'=>__('Agent Dashboard'));
+            $this->tabs['dashboard'] = array('desc'=>__('Dashboard'),'href'=>'dashboard.php','title'=>__('Agent Dashboard'), "class"=>"no-pjax");
             $this->tabs['users'] = array('desc' => __('Users'), 'href' => 'users.php', 'title' => __('User Directory'));
             $this->tabs['tickets'] = array('desc'=>__('Tickets'),'href'=>'tickets.php','title'=>__('Ticket Queue'));
             $this->tabs['kbase'] = array('desc'=>__('Knowledgebase'),'href'=>'kb.php','title'=>__('Knowledgebase'));
diff --git a/include/staff/templates/navigation.tmpl.php b/include/staff/templates/navigation.tmpl.php
index b28ec0526..8f0444999 100644
--- a/include/staff/templates/navigation.tmpl.php
+++ b/include/staff/templates/navigation.tmpl.php
@@ -1,7 +1,10 @@
 <?php
 if(($tabs=$nav->getTabs()) && is_array($tabs)){
     foreach($tabs as $name =>$tab) {
-        echo sprintf('<li class="%s"><a href="%s">%s</a>',$tab['active']?'active':'inactive',$tab['href'],$tab['desc']);
+        echo sprintf('<li class="%s %s"><a href="%s">%s</a>',
+            $tab['active'] ? 'active':'inactive',
+            @$tab['class'] ?: '',
+            $tab['href'],$tab['desc']);
         if(!$tab['active'] && ($subnav=$nav->getSubMenu($name))){
             echo "<ul>\n";
             foreach($subnav as $k => $item) {
diff --git a/scp/js/dashboard.inc.js b/scp/js/dashboard.inc.js
index 40a094ac2..683135e62 100644
--- a/scp/js/dashboard.inc.js
+++ b/scp/js/dashboard.inc.js
@@ -1,5 +1,5 @@
 (function ($) {
-    var current_tab;
+    var current_tab = null;
     function refresh(e) {
         $('#line-chart-here').empty();
         $('#line-chart-legend').empty();
@@ -135,6 +135,9 @@
             stop = this.period.value || 'now';
         }
 
+        if (!current_tab)
+            current_tab = $('#tabular-navigation li:first-child a');
+
         var group = current_tab.attr('table-group');
         var pagesize = 25;
         getConfig().then(function(c) { if (c.page_size) pagesize = c.page_size; });
@@ -262,10 +265,11 @@
         });
         return false;
     }
-   
-    $(function() { 
-        $('#timeframe-form').submit(refresh);
+
+    $(function() {
+        var form = $('#timeframe-form');
+        form.submit(refresh);
         //Trigger submit now...init.
-        $('#timeframe-form').submit(); 
-        });
+        form.submit();
+    });
 })(window.jQuery);
-- 
GitLab