add helper function for header and footer

This commit is contained in:
printempw 2016-09-15 11:04:08 +08:00
parent 41f24b9a3a
commit 8507860b15
6 changed files with 60 additions and 69 deletions

View File

@ -81,3 +81,52 @@ if (! function_exists('json')) {
}
}
}
if (! function_exists('bs_footer')) {
function bs_footer($page_identification = "")
{
$scripts = [
assets('js/app.min.js'),
assets('lang/'.session('locale', config('app.locale')).'/locale.js'),
assets('js/general.js')
];
if ($page_identification !== "") {
$scripts[] = assets("js/$page_identification.js");
}
foreach ($scripts as $script) {
echo "<script type=\"text/javascript\" src=\"$script\"></script>";
}
if (Session::has('msg')): ?>
<script>
toastr.info('{{ Session::pull('msg') }}');
</script>
<?php endif;
echo '<script>'.Option::get("custom_js").'</script>';
}
}
if (! function_exists('bs_header')) {
function bs_header($page_identification = "")
{
$styles = [
assets('css/app.min.css'),
assets('vendor/skins/'.Option::get('color_scheme').'.min.css')
];
if ($page_identification !== "") {
$styles[] = assets("css/$page_identification.css");
}
foreach ($styles as $style) {
echo "<link rel=\"stylesheet\" href=\"$style\">";
}
echo '<style>'.Option::get("custom_css").'</style>';
}
}

View File

@ -8,15 +8,9 @@
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- App Styles -->
<link rel="stylesheet" href="{{ assets('css/app.min.css') }}">
<!-- AdminLTE Skins -->
<link rel="stylesheet" href="{{ assets('vendor/skins/'.Option::get('color_scheme').'.min.css') }}">
<link rel="stylesheet" href="{{ assets('css/admin.css') }}">
{!! bs_header('admin') !!}
@yield('style')
<style>{!! Option::get('custom_css') !!}</style>
</head>
<?php $user = new App\Models\User(session('uid')); ?>
@ -138,9 +132,7 @@
</div><!-- ./wrapper -->
<!-- App Scripts -->
<script type="text/javascript" src="{{ assets('js/app.min.js') }}"></script>
<script type="text/javascript" src="{{ assets('js/admin.js') }}"></script>
{!! bs_footer('admin') !!}
@if (Option::get('check_update') == '1')
<script>
@ -155,7 +147,5 @@
@endif
@yield('script')
<script>{!! Option::get('custom_js') !!}</script>
</body>
</html>

View File

@ -7,13 +7,7 @@
<link rel="shortcut icon" href="{{ assets('images/favicon.ico') }}">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- App Styles -->
<link rel="stylesheet" href="{{ assets('css/app.min.css') }}">
<link rel="stylesheet" href="{{ assets('vendor/skins/'.Option::get('color_scheme').'.min.css') }}">
<link rel="stylesheet" href="{{ assets('css/auth.css') }}">
<style>{{ Option::get('custom_css') }}</style>
{!! bs_header('auth') !!}
</head>
<body class="hold-transition login-page">
@ -21,16 +15,8 @@
@yield('content')
<!-- App Scripts -->
<script type="text/javascript" src="{{ assets('js/app.min.js') }}"></script>
{!! bs_footer('auth') !!}
<script type="text/javascript" src="{{ assets('js/auth.js') }}"></script>
@if (Session::has('msg'))
<script>
toastr.info('{{ Session::pull('msg') }}');
</script>
@endif
<script>{!! Option::get('custom_js') !!}</script>
@yield('script')
</body>
</html>

View File

@ -8,18 +8,12 @@
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- App Styles -->
<link rel="stylesheet" href="{{ assets('css/app.min.css') }}">
<!-- AdminLTE Skins -->
<link rel="stylesheet" href="{{ assets('vendor/skins/'.Option::get('color_scheme').'.min.css') }}">
<link rel="stylesheet" href="{{ assets('css/index.css') }}">
{!! bs_header('index') !!}
<style>
.wrapper {
background-image: url('{{ Option::get('home_pic_url') }}');
}
{!! Option::get('custom_css') !!}
</style>
</head>
@ -122,8 +116,6 @@
</div><!-- ./wrapper -->
<!-- App Scripts -->
<script type="text/javascript" src="{{ assets('js/app.min.js') }}"></script>
<script>{!! Option::get('custom_js') !!}</script>
{!! bs_footer() !!}
</body>
</html>

View File

@ -8,15 +8,9 @@
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- App Styles -->
<link rel="stylesheet" href="{{ assets('css/app.min.css') }}">
<!-- AdminLTE Skins -->
<link rel="stylesheet" href="{{ assets('vendor/skins/'.Option::get('color_scheme').'.min.css') }}">
<link rel="stylesheet" href="{{ assets('css/skinlib.css') }}">
{!! bs_header('skinlib') !!}
@yield('style')
<style>{!! Option::get('custom_css') !!}</style>
</head>
<body class="hold-transition {{ Option::get('color_scheme') }} layout-top-nav">
@ -151,12 +145,8 @@
</div><!-- ./wrapper -->
<!-- App Scripts -->
<script type="text/javascript" src="{{ assets('js/app.min.js') }}"></script>
<script type="text/javascript" src="{{ assets('js/skinlib.js') }}"></script>
{!! bs_footer('skinlib') !!}
@yield('script')
<script>{!! Option::get('custom_js') !!}</script>
</body>
</html>

View File

@ -8,15 +8,9 @@
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- App Styles -->
<link rel="stylesheet" href="{{ assets('css/app.min.css') }}">
<!-- AdminLTE Skins -->
<link rel="stylesheet" href="{{ assets('vendor/skins/'.Option::get('color_scheme').'.min.css') }}">
<link rel="stylesheet" href="{{ assets('css/user.css') }}">
{!! bs_header('user') !!}
@yield('style')
<style>{!! Option::get('custom_css') !!}</style>
</head>
<body class="hold-transition {{ Option::get('color_scheme') }} sidebar-mini">
@ -139,18 +133,8 @@
</div><!-- ./wrapper -->
<!-- App Scripts -->
<script type="text/javascript" src="{{ assets('js/app.min.js') }}"></script>
<script type="text/javascript" src="{{ assets('js/user.js') }}"></script>
{!! bs_footer('user') !!}
@yield('script')
@if (Session::has('msg'))
<script>
toastr.info('{{ Session::pull('msg') }}');
</script>
@endif
<script>{!! Option::get('custom_js') !!}</script>
</body>
</html>