]> _ Git - fluidbook-toolbox.git/commitdiff
wait #5282 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 14 Oct 2022 15:04:21 +0000 (17:04 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 14 Oct 2022 15:04:21 +0000 (17:04 +0200)
resources/views/vendor/backpack/base/inc/scripts.blade.php [new file with mode: 0644]
resources/views/vendor/backpack/base/inc/sidebar_content.blade.php

diff --git a/resources/views/vendor/backpack/base/inc/scripts.blade.php b/resources/views/vendor/backpack/base/inc/scripts.blade.php
new file mode 100644 (file)
index 0000000..16d2e56
--- /dev/null
@@ -0,0 +1,65 @@
+@if (config('backpack.base.scripts') && count(config('backpack.base.scripts')))
+    @foreach (config('backpack.base.scripts') as $path)
+    <script type="text/javascript" src="{{ asset($path).'?v='.config('backpack.base.cachebusting_string') }}"></script>
+    @endforeach
+@endif
+
+@if (config('backpack.base.mix_scripts') && count(config('backpack.base.mix_scripts')))
+    @foreach (config('backpack.base.mix_scripts') as $path => $manifest)
+    <script type="text/javascript" src="{{ mix($path, $manifest) }}"></script>
+    @endforeach
+@endif
+
+@include('backpack::inc.alerts')
+
+<!-- page script -->
+<script type="text/javascript">
+    // To make Pace works on Ajax calls
+    // $(document).ajaxStart(function() { Pace.restart(); });
+
+    // polyfill for `startsWith` from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
+    if (!String.prototype.startsWith) {
+    Object.defineProperty(String.prototype, 'startsWith', {
+        value: function(search, rawPos) {
+            var pos = rawPos > 0 ? rawPos|0 : 0;
+            return this.substring(pos, pos + search.length) === search;
+        }
+    });
+    }
+
+
+
+    // polyfill for entries and keys from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries#polyfill
+    if (!Object.keys) Object.keys = function(o) {
+        if (o !== Object(o))
+            throw new TypeError('Object.keys called on a non-object');
+        var k=[],p;
+        for (p in o) if (Object.prototype.hasOwnProperty.call(o,p)) k.push(p);
+        return k;
+    }
+
+    if (!Object.entries) {
+        Object.entries = function( obj ){
+            var ownProps = Object.keys( obj ),
+                i = ownProps.length,
+                resArray = new Array(i); // preallocate the Array
+            while (i--)
+            resArray[i] = [ownProps[i], obj[ownProps[i]]];
+            return resArray;
+        };
+    }
+
+    // Ajax calls should always have the CSRF token attached to them, otherwise they won't work
+    $.ajaxSetup({
+        headers: {
+            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
+        }
+    });
+
+    {{-- Enable deep link to tab --}}
+    var activeTab = $('[href="' + location.hash.replace("#", "#tab_") + '"]');
+    location.hash && activeTab && activeTab.tab('show');
+    $('.nav-tabs a').on('shown.bs.tab', function (e) {
+        location.hash = e.target.hash.replace("#tab_", "#");
+    });
+</script>
index c31471a782208261c32ce13be4d148154cd9a660..34f7a382d8d7b714742bff3505b7e951c192d7b8 100644 (file)
@@ -9,15 +9,17 @@
 @push('after_scripts')
     <script>
         jQuery(document).ready(function ($) {
-            $(document).on('click', '.nav-dropdown', function () {
-                var dropdown = this;
+            $(document).on('click', '.nav-dropdown-toggle', function () {
+                var dropdown = $(this).closest('.nav-dropdown');
                 setTimeout(function () {
                     let newState = $(dropdown).hasClass('open') ? '1' : '0';
-                    $.ajax({
-                        url: '{{ backpack_url('toolbox_setting') }}',
-                        method: 'POST',
-                        data: {key: 'sidebar_' + $(dropdown).data('sidebar-id'), value: newState}
-                    })
+                    Pace.ignore(function () {
+                        $.ajax({
+                            url: '{{ backpack_url('toolbox_setting') }}',
+                            method: 'POST',
+                            data: {key: 'sidebar_' + $(dropdown).data('sidebar-id'), value: newState}
+                        })
+                    });
                 }, 500);
                 return true;
             });