/* 
 * Autor : Dhidhik
 * Date  : Desember 2015
 * Desc  : Setting template easyui untuk tampilan lebih responsive
 */



function updateSize() {
    var winWidth = $(window).width(),                // Ambil data lebar layar
            winHeight = $(window).height();          // Ambil data tinggi layar
    $(document).ready(function () {

        //====== filter kiri ==============//      
        //alert("winWidth="+winWidth);
        if( $(".layout-panel-west").length){
            if (winWidth < 700) {
                if ($(".layout-panel-west").css('display') == "block") {
                    $('.easyui-layout').layout('collapse', 'west');
                    //alert("panel dicollapse");
                }
            } else {
                if ($(".layout-panel-west").css('display') == "none") {
                    $('.easyui-layout').layout('expand', 'west');
                }
            }
        }else{
            //alert("class ga adaass");
        }            
        //====== End filter kiri ==============//


        $('#tt').css({"width": (winWidth - 2), "height": (winHeight - 47)});  //D
        $('#tt #ifmWindow').css({"width": (winWidth - 6), "height": (winHeight - 73), 'overflow': "hidden"});//iframe
        $("#tt").tabs('resize');
        //$(".panel-body").css({"overflow":"hidden"});
        $(".panel-body").css({"overflow-y":" auto","overflow-x":"hidden"});
        //====tab di page info company info =====//
        $('#tab_general').css({"width": "100%", "height": "100%"});//iframe
        $('#tab_tax').css({"width": "100%", "height": "100%"});//iframe
        //====end tab di page info company info =====//
        
        //====grid=====//
        $("#grid").datagrid('resize'); //semua table grid dgn nama "grid"
        //====end grid=====//

        //====== combo grid ==============//
        //$(".datagrid-btable").css({"width":200}); //semua table grid dgn class datagrid-btable    
        $(".easyui-numberbox").css({"width": "auto"}); //semua table grid dgn class .easyui-numberbox

        //======end combo grid ==============//
        
         //============= setting preference item ===========//
        //$('#centerPrefItem #form-wrapper').css({"width":($('#centerPrefItem').width()-4)});===========//
        $('#centerPrefItem #form-wrapper').css({"width":"100%"});         
//        $('#centerPrefItem #select_item_category').combo({
//            panelWidth:$('#centerPrefItem #select_item_category').width()
//        });
        $('#centerPrefItem select').combo({
            panelWidth:$('#centerPrefItem select').width()
        });
        $("#centerPrefItem .combo").addClass( "col-xs-12 col-sm-12 col-md-12" ); //
        $("#centerPrefItem .combo-arrow").attr("style","margin-left:-18px;height:20px;"); //
        $("#centerPrefItem .combo-text").css({"width":"100%"}); //
        $("#centerPrefItem .combo").removeAttr( "style" ); //       
        //alert("$('#centerPrefItem #select_item_category').width()="+$('#centerPrefItem #select_item_category').width());
         //============= setting combobox preference item ===========//
         
         
         //============= setting preference sales ===========//
        $('#centerPrefSales #form-wrapper').css({"width":"100%"});         
        
        $('#centerPrefSales select').combo({
            panelWidth:$('#centerPrefSales select').width()
        });
        $("#centerPrefSales .combo").addClass( "col-xs-12 col-sm-12 col-md-12" ); //
        $("#centerPrefSales .combo-arrow").attr("style","margin-left:-18px;height:20px;"); //
        $("#centerPrefSales .combo-text").css({"width":"100%"}); //
        $("#centerPrefSales .combo").removeAttr( "style" ); //        
         //============= setting preference sales ===========//
         
         //============= setting preference purchase ===========//
        $('#centerPrefPurchase #form-wrapper').css({"width":"100%"});         
        
        $('#centerPrefPurchase select').combo({
            panelWidth:$('#centerPrefPurchase select').width()
        });
        $("#centerPrefPurchase .combo").addClass( "col-xs-12 col-sm-12 col-md-12" ); //
        $("#centerPrefPurchase .combo-arrow").attr("style","margin-left:-18px;height:20px;"); //
        $("#centerPrefPurchase .combo-text").css({"width":"100%"}); //
        $("#centerPrefPurchase .combo").removeAttr( "style" ); //        
         //============= end setting preference purchase ===========//
         
        //=============== setting data di menu Preference->expend Account ==============//
        $("#wrapptabs").tabs('resize');
        //$("#tab_service_group").css({"width":"100%"});//data di menu Preference->expend Account->Tab Expend Catagory
        $("#dtg_category").datagrid('resize');                                  //data di menu Preference->expend Account->Tab Expend Catagory
        $("#dtg_detail").datagrid('resize');                                  //data di menu Preference->expend Account->Tab Expend Detail
        $("#wrapptabs .datagrid .datagrid-wrap").css({"height":"400"});  //data di menu Preference->expend Account->Tab Expend Catagory
                
        $('#tab_service_detail select').combo({                                 //data di menu Preference->expend Account->Tab Expend Detail
            panelWidth:$('#tab_service_detail select').width()                  
        });
        $("#tab_service_detail .combo").addClass( "col-xs-12 col-sm-12 col-md-12" );            //data di menu Preference->expend Account->Tab Expend Detail
//        $("#tab_service_detail .combo-p").addClass( "col-xs-12 col-sm-12 col-md-12" );            //data di menu Preference->expend Account->Tab Expend Detail
        $("#tab_service_detail .combo-arrow").attr("style","margin-left:-18px;height:20px;");   //data di menu Preference->expend Account->Tab Expend Detail
        $("#tab_service_detail .combo-text").css({"width":"100%"}); //data di menu Preference->expend Account->Tab Expend Detail
        $("#tab_service_detail .combo").removeAttr( "style" );      //data di menu Preference->expend Account->Tab Expend Detail
//        $("#tab_service_detail .combo-p").removeAttr( "style" );      //data di menu Preference->expend Account->Tab Expend Detail
        
        $('#tab_service_account select').combo({                                 //data di menu Preference->expend Account->Tab Expense Account
            panelWidth:$('#tab_service_account select').width()                  
        });
        $("#tab_service_account .combo").addClass( "col-xs-12 col-sm-12 col-md-12" );            //data di menu Preference->expend Account->Tab Expense Account
        $("#tab_service_account .combo-arrow").attr("style","margin-left:-18px;height:20px;");   //data di menu Preference->expend Account->Tab Expense Account
        $("#tab_service_account .combo-text").css({"width":"100%"}); //data di menu Preference->expend Account->Tab Expense Account
        $("#tab_service_account .combo").removeAttr( "style" );      //data di menu Preference->expend Account->Tab Expense Account
        //=============== End setting data di menu Preference->expend Account ==============//

    });

}

$(function () {
//$(document).ready(function(){
    $('#tt').tabs({"fit": true});
    $('#grid').datagrid({"fit": true});
    $('#dtg_category').datagrid({"fit": true});//data di menu Preference->expend Account->
    $('#dtg_detail').datagrid({"fit": true});//data di menu Preference->expend Account->
    
    $('#cmb_city').combogrid({"fit": true}); // di menu company info
    setTimeout(function () {
        updateSize();
    }, 250);
    $(window).resize(function () {
        clearTimeout(window.resizedFinished);
        window.resizedFinished = setTimeout(function () {
            updateSize();
        }, 250);
    });
});