Browse Source

Only include the trianglify JS when enabled.

ullbergm/trianglify
magnus Ullberg 7 years ago
parent
commit
6044894ebd
  1. 4
      app/Providers/AppServiceProvider.php
  2. 4
      resources/views/app.blade.php

4
app/Providers/AppServiceProvider.php

@ -17,7 +17,7 @@ class AppServiceProvider extends ServiceProvider
public function boot() public function boot()
{ {
$alt_bg = ''; $alt_bg = '';
$trianglify = ''; $trianglify = 'false';
if(!is_file(base_path('.env'))) { if(!is_file(base_path('.env'))) {
touch(base_path('.env')); touch(base_path('.env'));
@ -34,7 +34,7 @@ class AppServiceProvider extends ServiceProvider
if(is_file(database_path('app.sqlite'))) { if(is_file(database_path('app.sqlite'))) {
if(Schema::hasTable('settings')) { if(Schema::hasTable('settings')) {
if(Setting::fetch('trianglify')) { if(Setting::fetch('trianglify')) {
$trianglify = '<script>addTriangleTo(app);</script>'; $trianglify = 'true';
} else if($bg_image = Setting::fetch('background_image')) { } else if($bg_image = Setting::fetch('background_image')) {
$alt_bg = ' style="background-image: url(/storage/'.$bg_image.')"'; $alt_bg = ' style="background-image: url(/storage/'.$bg_image.')"';
} }

4
resources/views/app.blade.php

@ -91,6 +91,7 @@
<script>!window.jQuery && document.write('<script src="/js/jquery-3.3.1.min.js"><\/script>')</script> <script>!window.jQuery && document.write('<script src="/js/jquery-3.3.1.min.js"><\/script>')</script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="/js/app.js?v=2"></script> <script src="/js/app.js?v=2"></script>
@if ($trianglify == 'true')
<script src="/js/trianglify.min.js"></script> <script src="/js/trianglify.min.js"></script>
<script> <script>
function addTriangleTo(target) { function addTriangleTo(target) {
@ -114,7 +115,8 @@
}, 400); }, 400);
}); });
</script> </script>
{!! $trianglify !!} <script>addTriangleTo(app);</script>
@endif
@yield('scripts') @yield('scripts')
</body> </body>

Loading…
Cancel
Save