From 3157b5215af60610ffc5771582be12e23a0d5d77 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Fri, 17 Oct 2014 23:52:33 -0500 Subject: [PATCH] Remove unnecessary callback for config --- include/ajax.config.php | 9 ++++-- include/client/footer.inc.php | 7 ++++ js/osticket.js | 60 +++++++++++++++-------------------- 3 files changed, 39 insertions(+), 37 deletions(-) diff --git a/include/ajax.config.php b/include/ajax.config.php index 733fa014d..d2547d98c 100644 --- a/include/ajax.config.php +++ b/include/ajax.config.php @@ -13,6 +13,7 @@ vim: expandtab sw=4 ts=4 sts=4: **********************************************************************/ +require_once INCLUDE_DIR . 'class.ajax.php'; if(!defined('INCLUDE_DIR')) die('!'); @@ -42,7 +43,7 @@ class ConfigAjaxAPI extends AjaxController { return $this->json_encode($config); } - function client() { + function client($headers=true) { global $cfg; $lang = Internationalization::getCurrentLanguage(); @@ -62,8 +63,10 @@ class ConfigAjaxAPI extends AjaxController { ); $config = $this->json_encode($config); - Http::cacheable(md5($config), $cfg->lastModified()); - header('Content-Type: application/json; charset=UTF-8'); + if ($headers) { + Http::cacheable(md5($config), $cfg->lastModified()); + header('Content-Type: application/json; charset=UTF-8'); + } return $config; } diff --git a/include/client/footer.inc.php b/include/client/footer.inc.php index 9ff4ad152..9521fbfc7 100644 --- a/include/client/footer.inc.php +++ b/include/client/footer.inc.php @@ -14,5 +14,12 @@ if (($lang = Internationalization::getCurrentLanguage()) && $lang != 'en_US') { <script type="text/javascript" src="ajax.php/i18n/<?php echo $lang; ?>/js"></script> <?php } ?> +<script type="text/javascript"> + getConfig().resolve(<?php + include INCLUDE_DIR . 'ajax.config.php'; + $api = new ConfigAjaxAPI(); + print $api->client(false); + ?>); +</script> </body> </html> diff --git a/js/osticket.js b/js/osticket.js index f4aeebd1a..911cbf4e7 100644 --- a/js/osticket.js +++ b/js/osticket.js @@ -78,39 +78,6 @@ $(document).ready(function(){ }); - getConfig = (function() { - var dfd = $.Deferred(), - requested = false; - return function() { - if (dfd.state() != 'resolved' && !requested) - requested = $.ajax({ - url: "ajax.php/config/client", - dataType: 'json', - success: function (json_config) { - dfd.resolve(json_config); - } - }); - return dfd; - } - })(); - - $.translate_format = function(str) { - var translation = { - 'd':'dd', - 'j':'d', - 'z':'o', - 'm':'mm', - 'F':'MM', - 'n':'m', - 'Y':'yy' - }; - // Change PHP formats to datepicker ones - $.each(translation, function(php, jqdp) { - str = str.replace(php, jqdp); - }); - return str; - }; - var showNonLocalImage = function(div) { var $div = $(div), $img = $div.append($('<img>') @@ -199,7 +166,32 @@ showImagesInline = function(urls, thread_id) { e.data('wrapped', true); } }); -} +}; + +getConfig = (function() { + var dfd = $.Deferred(), + requested = false; + return function() { + return dfd; + }; +})(); + +$.translate_format = function(str) { + var translation = { + 'd':'dd', + 'j':'d', + 'z':'o', + 'm':'mm', + 'F':'MM', + 'n':'m', + 'Y':'yy' + }; + // Change PHP formats to datepicker ones + $.each(translation, function(php, jqdp) { + str = str.replace(php, jqdp); + }); + return str; +}; $.sysAlert = function (title, msg, cb) { var $dialog = $('.dialog#alert'); -- GitLab