
/*
* 로그아웃
* */
const logout = function(){
  ajax_json({
    url: "/kadm/inc/common.ajax.php",
    type: "POST",
    data: {mode: 'adminLogout'},
    success: function (data) {
      if ( data.code ) {
        kuls_alert("로그아웃 되었습니다.",function(){
          location.href="/kadm/";
        });
      }
    },
    error: function (request, status, error) {
      kuls_alert(error.message);
    }
  });
};

const menu_toggle = function(){
  jQuery("#root").toggleClass("full-width");
}

const cont_hfix = function(){
  jQuery(".cont_hfix").css('height',0);
  let win_h = jQuery(window).height();
  jQuery(".cont_hfix").toArray().forEach( tgt => {
    let cont_y = jQuery(tgt).offset().top;
    let cont_height = win_h - cont_y - 20;
    jQuery(tgt).css('height',cont_height);
  });
}

const menu_mobile = function(){
  let win_w = jQuery(window).innerWidth();
  if( win_w < 640 ){
    jQuery("#root").addClass("full-width");
  }else{
    jQuery("#root").removeClass("full-width");
  }
}

jQuery(document).ready(function(){
  jQuery(".btn-sidemenu").on("click",menu_toggle);
  
  //사이드메뉴 스크롤바
  if( document.querySelector('#side-nav') ){
    new PerfectScrollbar(document.querySelector('#side-nav'));
  }

  window.setTimeout(function(){ //vue 동작때문에
    cont_hfix();
    menu_mobile();
  },100);
});

jQuery(window).on("resize",function(){
  cont_hfix();
  menu_mobile();
});