Removed global Javascript variables

This commit is contained in:
Marcin Kurczewski 2014-08-08 20:00:55 +02:00
parent b97726f6ff
commit f78d09b424
3 changed files with 11 additions and 9 deletions

View file

@ -27,7 +27,7 @@ function getCookie(name)
function rememberLastSearchQuery() function rememberLastSearchQuery()
{ {
//lastSearchQuery variable is obtained from layout var lastSearchQuery = $('#settings').attr('data-last-search-query');
setCookie('last-search-query', lastSearchQuery); setCookie('last-search-query', lastSearchQuery);
} }

View file

@ -35,6 +35,8 @@ function toggleTagEventHandler(e)
function alignPosts() function alignPosts()
{ {
var thumbnailWidth = $('#settings').attr('data-thumbnail-width');
var thumbnailHeight = $('#settings').attr('data-thumbnail-width');
var samplePost = $('.posts .post:last-child'); var samplePost = $('.posts .post:last-child');
var container = $('.posts'); var container = $('.posts');
samplePost.find('.thumb').css('width', thumbnailWidth + 'px'); samplePost.find('.thumb').css('width', thumbnailWidth + 'px');

View file

@ -11,6 +11,9 @@ if (!empty(Core::getConfig()->appearance->extraScripts))
if (!empty(Core::getConfig()->appearance->extraStylesheets)) if (!empty(Core::getConfig()->appearance->extraStylesheets))
foreach (Core::getConfig()->appearance->extraStylesheets as $path) foreach (Core::getConfig()->appearance->extraStylesheets as $path)
$this->assets->addStylesheetFullPath($path); $this->assets->addStylesheetFullPath($path);
$lastSearchQuery = isset($this->context->transport->lastSearchQuery)
? $this->context->transport->lastSearchQuery
: '';
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
@ -26,14 +29,11 @@ if (!empty(Core::getConfig()->appearance->extraStylesheets))
</head> </head>
<body> <body>
<script type="text/javascript"> <div id="settings"
var lastSearchQuery = <?= json_encode( data-last-search-query="<?= htmlspecialchars($lastSearchQuery) ?>"
isset($this->context->transport->lastSearchQuery) data-thumbnail-width="<?= Core::getConfig()->browsing->thumbnailWidth ?>"
? $this->context->transport->lastSearchQuery data-thumbnail-height="<?= Core::getConfig()->browsing->thumbnailHeight ?>">
:'') ?>; </div>
var thumbnailWidth = <?= Core::getConfig()->browsing->thumbnailWidth ?>;
var thumbnailHeight = <?= Core::getConfig()->browsing->thumbnailHeight ?>;
</script>
<nav id="top-nav"> <nav id="top-nav">
<div class="main-wrapper"> <div class="main-wrapper">