diff --git a/include/class.osticket.php b/include/class.osticket.php index abd563839d6be9910ae4446f4aaf71694b1dc96b..ce5d6354498dbb022ec66213f756eb49ffb1c69b 100644 --- a/include/class.osticket.php +++ b/include/class.osticket.php @@ -42,6 +42,7 @@ class osTicket { var $title; //Custom title. html > head > title. var $headers; + var $pjax_extra; var $config; var $session; @@ -163,13 +164,17 @@ class osTicket { return $replacer->replaceVars($input); } - function addExtraHeader($header) { + function addExtraHeader($header, $pjax_script=false) { $this->headers[md5($header)] = $header; + $this->pjax_extra[md5($header)] = $pjax_script; } function getExtraHeaders() { return $this->headers; } + function getExtraPjax() { + return $this->pjax_extra; + } function setPageTitle($title) { $this->title = $title; diff --git a/include/staff/footer.inc.php b/include/staff/footer.inc.php index 858874e0767d2d12e9061d3611a1fdebc55aa951..f7f2d5024213aca1dc60291825c2bdd0aba12758 100644 --- a/include/staff/footer.inc.php +++ b/include/staff/footer.inc.php @@ -25,7 +25,7 @@ if(is_object($thisstaff) && $thisstaff->isStaff()) { ?> if ($.support.pjax) { $(document).on('click', 'a', function(event) { if (!$(this).hasClass('no-pjax')) - $.pjax.click(event, {container: $('#content')}) + $.pjax.click(event, {container: $('#content'), timeout: 2000}) }) } </script> diff --git a/include/staff/header.inc.php b/include/staff/header.inc.php index ac0e62594a04433846d10284b0354253bff1e5f5..9de588c436e41dbe00139a4849ccadb72a93507d 100644 --- a/include/staff/header.inc.php +++ b/include/staff/header.inc.php @@ -113,7 +113,11 @@ } ?> </ul> - <div id="content" data-pjax-container> + <div id="content"> +<?php } elseif ($pjax = $ost->getExtraPjax()) { # endif X_PJAX ?> + <script type="text/javascript"> + <?php foreach ($pjax as $s) echo $s.";"; ?> + </script> <?php } # endif X_PJAX ?> <?php if($errors['err']) { ?> <div id="msg_error"><?php echo $errors['err']; ?></div> diff --git a/scp/forms.php b/scp/forms.php index 43e66242aa85f55ea2baad290a9fa29369990055..18303449ea47b4be66e13baa7db94a79b3299a77 100644 --- a/scp/forms.php +++ b/scp/forms.php @@ -126,7 +126,8 @@ $page='dynamic-forms.inc.php'; if($form || ($_REQUEST['a'] && !strcasecmp($_REQUEST['a'],'add'))) $page='dynamic-form.inc.php'; -$ost->addExtraHeader('<meta name="tip-namespace" content="forms" />'); +$ost->addExtraHeader('<meta name="tip-namespace" content="forms" />', + "$('#content').data('tipNamespace', 'forms');"); $nav->setTabActive('manage'); require(STAFFINC_DIR.'header.inc.php'); require(STAFFINC_DIR.$page); diff --git a/scp/js/tips.js b/scp/js/tips.js index 9fdd2261701abc3c60012dd54a6ebe10a6b548fc..a4a9e8b4c61cb7499c9cefc9b123ad29a0ec8390 100644 --- a/scp/js/tips.js +++ b/scp/js/tips.js @@ -24,20 +24,26 @@ jQuery(function() { }); }, getHelpTips = (function() { - var dfd = $.Deferred(), - requested = false, - namespace = $('meta[name=tip-namespace]').attr('content'); - return function() { - if (namespace && dfd.state() != 'resolved' && !requested) - requested = $.ajax({ + var dfd, cache = {}; + return function(namespace) { + var namespace = namespace + || $('#content').data('tipNamespace') + || $('meta[name=tip-namespace]').attr('content'); + if (!namespace) + return false; + else if (!cache[namespace]) + cache[namespace] = { + dfd: dfd = $.Deferred(), + ajax: $.ajax({ url: "ajax.php/help/tips/" + namespace, dataType: 'json', - success: function (json_config) { - dfd.resolve(json_config); - } - }); - return dfd; - } + success: $.proxy(function (json_config) { + this.resolve(json_config); + }, dfd) + }) + } + return cache[namespace].dfd; + }; })(); //Generic tip. diff --git a/scp/settings.php b/scp/settings.php index a4243fd957fb780eea3b151fd96c8b9770ef9ccb..96ee4b97c20c50fde39cce47bc9f28edeb83a1c9 100644 --- a/scp/settings.php +++ b/scp/settings.php @@ -48,7 +48,8 @@ if($page && $_POST && !$errors) { } $config=($errors && $_POST)?Format::input($_POST):Format::htmlchars($cfg->getConfigInfo()); -$ost->addExtraHeader('<meta name="tip-namespace" content="'.$page[1].'" />'); +$ost->addExtraHeader('<meta name="tip-namespace" content="'.$page[1].'" />', + "$('#content').data('tipNamespace', '".$page[1]."');"); $nav->setTabActive('settings', ('settings.php?t='.$target)); require_once(STAFFINC_DIR.'header.inc.php');