]> _ Git - cubist_cms-back.git/commitdiff
#2843
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 25 Jun 2019 16:10:40 +0000 (18:10 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 25 Jun 2019 16:10:40 +0000 (18:10 +0200)
composer.json
src/CubistBackpackServiceProvider.php
src/app/helpers.php [new file with mode: 0644]
src/public/bunchmultiple/bunchmultiple.js [new file with mode: 0644]
src/public/bunchmultiple/bunchmultiple.less [new file with mode: 0644]
src/resources/views/fields/bunch_multiple.blade.php

index bc6a4b70070110e7fbb03e9bd25f27b513630424..3329f2e4687d2c7176af838dcf84059ea89fff97 100644 (file)
@@ -8,7 +8,10 @@
     "autoload": {
         "psr-0": {
             "Cubist\\Backpack\\": "src"
-        }
+        },
+        "files": [
+            "app/helpers.php"
+        ]
     },
     "authors": [
         {
index 024f82ad0a795bd83b49f462758a612bb4baf597..5d0c88dd825965e8c79719e69d162fd2f6d0deb1 100644 (file)
@@ -5,6 +5,7 @@ namespace Cubist\Backpack;
 use Cubist\Backpack\app\Console\Command\MigrateCommand;
 use Cubist\Backpack\app\Console\Commands\GenerateCommand;
 use Cubist\Backpack\app\Console\Commands\InstallCommand;
+use Illuminate\Support\Facades\Blade;
 use Illuminate\Support\ServiceProvider;
 
 class CubistBackpackServiceProvider extends ServiceProvider
@@ -32,6 +33,9 @@ class CubistBackpackServiceProvider extends ServiceProvider
         }
         $this->loadViewsFrom(realpath(__DIR__ . '/resources/views'), self::NAMESPACE);
 
+        Blade::directive('vendorasset', function ($path) {
+
+        });
     }
 
 
diff --git a/src/app/helpers.php b/src/app/helpers.php
new file mode 100644 (file)
index 0000000..5e8550b
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+if (!function_exists(vendor_asset)) {
+    function vendor_asset($path)
+    {
+        return asset($path);
+    }
+}
diff --git a/src/public/bunchmultiple/bunchmultiple.js b/src/public/bunchmultiple/bunchmultiple.js
new file mode 100644 (file)
index 0000000..d255e1a
--- /dev/null
@@ -0,0 +1,37 @@
+(function ($) {
+    function JQbunchmultiple(element) {
+        this.element = element;
+        this.init();
+    }
+
+    JQbunchmultiple.prototype = {
+        init: function () {
+            var $this = this;
+            var initValues = this.data('values');
+            $.each(initValues, function (k, v) {
+                $this.initItem(v);
+            });
+            if (initValues.length === 0) {
+                this.initItem({});
+            }
+        },
+
+        initItem: function (values) {
+            var item = this.element.find('.sample').clone();
+            $(".bunchmultiple__items").append($(item));
+        },
+    };
+
+    jQuery.fn.bunchmultiple = function () {
+        return this.each(function () {
+            var $this = $(this);
+            if ($(this).data('bunchmultiple') === undefined) {
+                $(this).data('bunchmultiple', new JQbunchmultiple($this));
+            }
+        })
+    };
+})(jQuery);
+
+jQuery(document).ready(function ($) {
+    $(".bunchmultiple").bunchmultiple();
+});
diff --git a/src/public/bunchmultiple/bunchmultiple.less b/src/public/bunchmultiple/bunchmultiple.less
new file mode 100644 (file)
index 0000000..05fb41f
--- /dev/null
@@ -0,0 +1,23 @@
+.bunchmultiple {
+    .bunchmultiple__wrapper {
+        padding: 15px;
+        border: 1px solid #eee;
+        background: #fafafa;
+        margin-bottom: 15px;
+
+        > .form-group {
+            padding: 0;
+
+            > label {
+                font-size: 1.2em;
+                margin-bottom: 24px;
+            }
+        }
+
+        .sample {
+            display: none;
+        }
+    }
+}
+
+
index 3d2d063ba8090f0d5c7f2e357a91ed36cf2120c9..5fdfc7e1bd11bca2284903c8041d6efdcd769d15 100644 (file)
@@ -14,15 +14,18 @@ if (!is_string($value)) {
 $unique = 'bunchmultiple_' . rand(1, 100000);
 
 ?>
-<div class="bunchmultiple__margin col-xs-12" id="{!! $unique !!}" data-values="{!! $value !!}">
+<div class="bunchmultiple col-xs-12" id="{!! $unique !!}" data-values="{!! $value !!}">
     <div class="bunchmultiple__wrapper col-xs-12">
         <div @include('crud::inc.field_wrapper_attributes') >
             <label>{!! $field['label'] !!}</label>
             @include('crud::inc.field_translatable_icon')
             <div class="clearfix"></div>
 
-            <div class="sample">
-                @include('cubist_back::inc.show_bunch_fields', array('bunchfields'=>$field['bunchfields']))
+            <div class="bunchmultiple__items">
+                <div class="item sample">
+                    <div class="legend">move Editer +-</div>
+                    @include('cubist_back::inc.show_bunch_fields', array('bunchfields'=>$field['bunchfields']))
+                </div>
             </div>
 
             <div class="clearfix"></div>
@@ -43,38 +46,12 @@ $unique = 'bunchmultiple_' . rand(1, 100000);
 
     {{-- FIELD CSS - will be loaded in the after_styles section --}}
     @push('crud_fields_styles')
-        <style type="text/css">
-
-            .bunch__margin {
-                margin: 15px 0;
-            }
-
-            .bunch__wrapper {
-                padding: 15px;
-                border: 1px solid #eee;
-                background: #fafafa;
-                margin-bottom: 15px;
-            }
-
-            .bunch__wrapper .form-group {
-                padding: 0;
-            }
-
-            .bunch__wrapper > .form-group > label {
-                font-size: 1.2em;
-                margin-bottom: 24px;
-            }
-        </style>
+        <link rel="stylesheet" type="text/css" href="{{ vendorasset('vendor/cubist/backpack/bunchmultiple.css') }}">
     @endpush
 
     {{-- FIELD JS - will be loaded in the after_scripts section --}}
     @push('crud_fields_scripts')
-        <script>
-            jQuery(document).ready(function ($) {
-
-
-            });
-        </script>
+        <script type="text/javascript" src="{{ vendorasset('vendor/cubist/backpack/bunchmultiple.js') }}"></script>
     @endpush
 
 @endif