//TEAM MEMBER 
// Auto expand the Text Area as content increases   
$("textarea").each(function () {
    this.setAttribute("style", "height:" + (this.scrollHeight) + "px;overflow-y:hidden;border:1px solid #ced4da;");
  }).on("input", function () {
    this.style.height = "auto";
    this.style.height = (this.scrollHeight) + "px";
  }).on("click", function () {
    // Display the entire content when clicked to edit
    this.style.height = (this.scrollHeight) + "px";
  });

//Load image in preview window
function readImage(file) {
    var reader = new FileReader();
    var image = new Image();
    reader.readAsDataURL(file);
    reader.onload = function(_file) {
      image.src = _file.target.result; // url.createObjectURL(file);
      image.onload = function() {
        var w = this.width,
        h = this.height,
        t = file.type, // ext only: // file.type.split('/')[1],
        n = file.name,
        s = file.size;
          //console.log(s);
          if (file.size > 2097152) 
          {
            toastr.error('Image too large: ' + file.size+'. Try less than 2MB!');
          }else {
            $('#postImgPreview').append('<img src="' + this.src + '" class="img-thumbnail thumb" style="height: 250px">');
          };
      };
      image.onerror = function() {
          toastr.error('Invalid file type: ' + file.type);
      };
    };
  }
  $("#post_image").change(function(e) {
    if(this.disabled){
      toastr.error('Sorry! File upload not supported!');
    }
    let numOfFiles = 0;
    var F = this.files;
    if(F && F[0]) 
    {
      if(numOfFiles + F.length > 1)
      {
  //      $("#postImg").attr("disabled", "disabled");
          toastr.error('You can only upload at most 1 Images!');
      }else{
        for(var i = 0; i < F.length; i++) { 
        readImage(F[i]);
        } 
      }  
    }
  });


function delete_teamCategory(id, name){
    var confirmation = confirm('Are you sure you want to delete '+ name +' page?');
    if(confirmation == true){
        window.location.href = base_url + ('administrator/team/categories/delete/')+ id;
    }
}

function delete_member(id, name){
  var confirmation = confirm('Are you sure you want to delete '+ name +' profile?');
  if(confirmation == true){
      window.location.href = base_url + ('administrator/team/member/delete/')+ id;
  }
}