1
0
Daniel Supernault 6 жил өмнө
parent
commit
cdb30c8e27

+ 29 - 49
resources/views/settings/home.blade.php

@@ -72,7 +72,32 @@
 
 @push('scripts')
 <script type="text/javascript">
-  $(document).on('click', '.modal-update', function(e) {
+
+  $(document).on('click', '.modal-close', function(e) {
+    swal.close();
+  });
+
+  $('#bio').on('change keyup paste', function(e) {
+    let el = $(this);
+    let len = el.val().length;
+    let limit = el.data('max-length');
+
+    if(len > 100) {
+      el.attr('rows', '4');
+    }
+
+    let val = len + ' / ' + limit;
+
+    if(len > limit) {
+      let diff = len - limit;
+      val = '<span class="text-danger">-' + diff + '</span> / ' + limit;
+    }
+
+    $('.bio-counter').html(val);
+  });
+
+  $(document).on('click', '.change-profile-photo', function(e) {
+    e.preventDefault();
     swal({
       title: 'Upload Photo',
       content: {
@@ -90,6 +115,9 @@
         }
       }
     }).then((res) => {
+      if(!res) {
+        return;
+      }
       const input = $('#photoUploadInput')[0];
       const photo = input.files[0];
       const form = new FormData();
@@ -107,53 +135,5 @@
       });
     });
   });
-
-  $(document).on('click', '.modal-close', function(e) {
-    swal.close();
-  });
-
-  $('#bio').on('change keyup paste', function(e) {
-    let el = $(this);
-    let len = el.val().length;
-    let limit = el.data('max-length');
-
-    if(len > 100) {
-      el.attr('rows', '4');
-    }
-
-    let val = len + ' / ' + limit;
-
-    if(len > limit) {
-      let diff = len - limit;
-      val = '<span class="text-danger">-' + diff + '</span> / ' + limit;
-    }
-
-    $('.bio-counter').html(val);
-  });
-
-  $(document).on('click', '.change-profile-photo', function(e) {
-    e.preventDefault();
-    var content = $('<ul>').addClass('list-group');
-    var upload = $('<li>').text('Upload photo').addClass('list-group-item');
-    content.append(upload);
-    const list = document.createElement('ul');
-    list.className = 'list-group';
-
-    const uploadPhoto = document.createElement('li');
-    uploadPhoto.innerHTML = 'Upload Photo';
-    uploadPhoto.className = 'list-group-item font-weight-bold text-primary modal-update';
-    list.appendChild(uploadPhoto);
-
-    const cancel = document.createElement('li');
-    cancel.innerHTML = 'Cancel';
-    cancel.className = 'list-group-item modal-close';
-    list.appendChild(cancel);
-
-    swal({
-      title: 'Change Profile Photo',
-      content: list,
-      buttons: false
-    });
-  });
 </script>
 @endpush