Răsfoiți Sursa

Adding sweetalert plugins to delete dialog box - refs #2681

Alex Aragón 6 ani în urmă
părinte
comite
93dff21497

+ 1 - 1
assets/js/app.js

@@ -4,8 +4,8 @@ import Routing from '../../vendor/friendsofsymfony/jsrouting-bundle/Resources/pu
 
 Routing.setRoutingData(routes);
 
-require('./main');
 require('./vendor');
+require('./main');
 
 // @todo rework url naming
 var homePublicUrl = Routing.generate('home') + 'public/';

+ 2 - 23
assets/js/main.js

@@ -1,21 +1,12 @@
-// HEADER
 
-/*$(window).resize(function(){
+$(window).resize(function(){
     var widthScreen = $(window).width();
     if(widthScreen >= 1400){
         $('body').addClass('sidebar-lg-show');
     } else {
         $('body').removeClass('sidebar-lg-show');
     }
-    var main = $('#app-main');
-    var cardMain = $('#card-container');
-    var highAverage = main.height() - cardMain.height()-100;
-
-    cardMain.css("height", highAverage+cardMain.height()+"px");
-    if(cardMain.height()>850){
-        cardMain.css("height", "auto");
-    }
-});*/
+});
 
 $(function () {
 
@@ -25,19 +16,7 @@ $(function () {
     if(widthScreen >= 1400){
         $('body').addClass('sidebar-lg-show');
     }
-    /*
-    // Calculation of Width for Card Container
 
-    var main = $('#app-main');
-    var cardMain = $('#card-container');
-    var highAverage = main.height() - cardMain.height()-100;
-
-    //cardMain.css("height", highAverage+cardMain.height()+"px");
-    cardMain.css("height", highAverage+cardMain.height()+"px");
-    if(cardMain.height()>850 || widthScreen <= 600){
-        cardMain.css("height", "auto");
-    }
-*/
     //Elevator Scroll
     $(window).scroll(function () {
         if ($(this).scrollTop() > 50) {

+ 1 - 1
assets/js/vendor.js

@@ -23,7 +23,7 @@ require("jquery.scrollbar");
 require("blueimp-file-upload");
 require("select2");
 require("timeago");
-//require("datatables/media/js/jquery.dataTables");
+require("sweetalert/dist/sweetalert.min");
 require('bootstrap-select/dist/js/bootstrap-select.js');
 
 require("bootstrap-daterangepicker");

+ 2 - 4
main/inc/introductionSection.inc.php

@@ -330,9 +330,8 @@ if ($intro_dispCommand) {
             $tool = [
                 'name' => get_lang('ConfirmYourChoice'),
                 'url' => api_get_self()."?".api_get_cidreq().$blogParam."&intro_cmdDel=1",
-                'onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).
-                    "')) return false",
                 'icon' => 'fas fa-trash-alt',
+                'class' => 'delete-swal'
             ];
             $toolbar[] = $tool;
         } else {
@@ -346,9 +345,8 @@ if ($intro_dispCommand) {
             $tool = [
                 'name' => get_lang('ConfirmYourChoice'),
                 'url' => api_get_self()."?".api_get_cidreq()."&intro_cmdDel=1",
-                'onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_ilang('ConfirmYourChoice'), ENT_QUOTES, $charset)).
-                    "')) return false",
                 'icon' => 'fas fa-trash-alt',
+                'class' => 'delete-swal'
             ];
             $toolbar[] = $tool;
         }

+ 2 - 2
main/template/default/auth/introduction_section.html.twig

@@ -4,8 +4,8 @@
             <div class="toolbar">
                 <div class="btn-group btn-group-sm" role="group" aria-label="">
                     {% for item in toolbar %}
-                        <a href="{{ item.url }}" onclick="{{ (item.onclick!='')? item.onclick : '' }}"
-                           title="{{ item.name }}" class="btn btn-light">
+                        <a href="{{ item.url }}"
+                           title="{{ item.name }}" class="btn btn-light {{ item.class }}">
                             <i class="{{ item.icon }}"></i>
                         </a>
                     {% endfor %}

+ 1 - 0
package.json

@@ -43,6 +43,7 @@
     "qtip2": "^3.0.3",
     "select2": "^4.0.6-rc.1",
     "simplewebrtc": "^3.0.2",
+    "sweetalert": "^2.1.2",
     "timeago": "^1.6.3",
     "timepicker": "^1.11.14",
     "uglifyjs-webpack-plugin": "^1.3.0",

+ 25 - 0
src/ThemeBundle/Resources/views/Layout/base-layout.html.twig

@@ -94,6 +94,31 @@
         </div>
     </div>
 </div>
+<script type="text/javascript">
+    // MODAL DELETE CONFIRM
 
+    $('.delete-swal').click(function (e) {
+        e.preventDefault(); // Prevent the href from redirecting directly
+        var linkURL = $(this).attr("href");
+        var title = $(this).attr("title");
+        deleteConfirm(linkURL, title);
+    })
+    function deleteConfirm(linkURL, title){
+        swal({
+            //title: '{{ 'Warning'|trans }}',
+            text: title,
+            icon: "warning",
+            buttons: true,
+            dangerMode: true,
+        }).then((willDelete) => {
+            if (willDelete) {
+                window.location.href = linkURL;
+            }
+        });
+    }
+
+
+
+</script>
 </body>
 </html>