Commit 7876c837 authored by Ad Schellevis's avatar Ad Schellevis Committed by Franco Fichtner

(theme) add support for custom theme.js hook

(cherry picked from commit d82608e1)
(cherry picked from commit 6f2bd698)
(cherry picked from commit c34ac4df)
(cherry picked from commit 1af75a82)
parent 8ac9c16b
......@@ -410,6 +410,14 @@ function display_login_form($Login_Error = '')
<link href="/ui/themes/<?= $themename ?>/build/css/main.css" rel="stylesheet">
<link href="/ui/themes/<?= $themename ?>/build/images/favicon.png" rel="shortcut icon">
<!-- JQuery -->
<script type="text/javascript" src="/ui/js/jquery-1.12.0.min.js"></script>
<?php
if (file_exists("/usr/local/opnsense/www/themes/".$themename."/build/js/theme.js")):?>
<script type="text/javascript" src="/ui/themes/<?=$themename?>/build/js/theme.js"></script>
<?php
endif;?>
<!--[if lt IE 9]><script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js"></script><![endif]-->
......
......@@ -41,6 +41,12 @@ $di->set('view', function () use ($config) {
'compiledPath' => $config->application->cacheDir,
'compiledSeparator' => '_'
));
// register additional volt template functions
$volt->getCompiler()->addFunction('javascript_include_when_exists', function($local_url) {
$chk_path = "str_replace('/ui/','/usr/local/opnsense/www/',".$local_url.")";
$js_tag = "'<script type=\"text/javascript\" src=\"'.$local_url.'\"></script>'";
return "file_exists(".$chk_path.") ? ".$js_tag." :''";
});
return $volt;
},
......
......@@ -14,9 +14,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>{{title|default("OPNsense") }}</title>
{% set theme_name = ui_theme|default('opnsense') %}
<!-- include (theme) style -->
<link href="/ui/themes/{{ui_theme|default('opnsense')}}/build/css/main.css" rel="stylesheet">
<!-- include (theme) style -->
<link href="/ui/themes/{{theme_name}}/build/css/main.css" rel="stylesheet">
<!-- TODO: move to theme style -->
<style>
......@@ -30,16 +31,16 @@
</style>
<!-- Favicon -->
<link href="/ui/themes/{{ui_theme|default('opnsense')}}/build/images/favicon.png" rel="shortcut icon">
<link href="/ui/themes/{{theme_name}}/build/images/favicon.png" rel="shortcut icon">
<!-- Stylesheet for fancy select/dropdown -->
<link rel="stylesheet" type="text/css" href="/ui/themes/{{ui_theme|default('opnsense')}}/build/css/bootstrap-select.css">
<!-- Stylesheet for fancy select/dropdown -->
<link rel="stylesheet" type="text/css" href="/ui/themes/{{theme_name}}/build/css/bootstrap-select.css">
<!-- bootstrap dialog -->
<link href="/ui/themes/{{ui_theme|default('opnsense')}}/build/css/bootstrap-dialog.css" rel="stylesheet" type="text/css" />
<link href="/ui/themes/{{theme_name}}/build/css/bootstrap-dialog.css" rel="stylesheet" type="text/css" />
<!-- Font awesome -->
<link rel="stylesheet" href="/ui/css/font-awesome.min.css">
<!-- Font awesome -->
<link rel="stylesheet" href="/ui/css/font-awesome.min.css">
<!-- JQuery -->
<script type="text/javascript" src="/ui/js/jquery-1.12.0.min.js"></script>
......@@ -163,6 +164,7 @@
<script type="text/javascript" src="/ui/js/opnsense.js"></script>
<script type="text/javascript" src="/ui/js/opnsense_ui.js"></script>
<script type="text/javascript" src="/ui/js/opnsense_bootgrid_plugin.js"></script>
{{javascript_include_when_exists('/ui/themes/' ~ theme_name ~ '/build/js/theme.js')}}
</head>
<body>
......@@ -171,8 +173,8 @@
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="/">
<img class="brand-logo" src="/ui/themes/{{ui_theme|default('opnsense')}}/build/images/default-logo.png" height="30" alt="logo"/>
<img class="brand-icon" src="/ui/themes/{{ui_theme|default('opnsense')}}/build/images/icon-logo.png" height="30" alt="icon"/>
<img class="brand-logo" src="/ui/themes/{{theme_name}}/build/images/default-logo.png" height="30" alt="logo"/>
<img class="brand-icon" src="/ui/themes/{{theme_name}}/build/images/icon-logo.png" height="30" alt="icon"/>
</a>
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navigation">
<span class="sr-only">Toggle navigation</span>
......
......@@ -237,4 +237,9 @@ $pagetitle .= sprintf(' | %s.%s', $config['system']['hostname'], $config['system
});
//]]>
</script>
<?php
if (file_exists("/usr/local/opnsense/www/themes/".$themename."/build/js/theme.js")):?>
<script type="text/javascript" src="/ui/themes/<?=$themename?>/build/js/theme.js"></script>
<?php
endif;?>
</head>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment