diff --git a/include/ajax.config.php b/include/ajax.config.php index 733fa014d2c18af5e09d92c5b3ba497561f1b8ca..d2547d98c4abd967837d9a49073ff29b64bc5d32 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 9ff4ad15265c68a7a7938535786cae3ea9f910db..9521fbfc73a61d03735241bf4a6890b98c13b4a0 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 f4aeebd1a1075541fadb34c70f4f49ce6fd70452..911cbf4e758ab7b185837dfe8a51855e692d48c4 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');