<!--#include file="Sort_Fun.asp" -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link href="<%=sitepath%>css/bootstrap.min.css" rel="stylesheet">
<link href="<%=sitepath%>css/font-awesome.min.css" rel="stylesheet">
<link href="<%=sitepath%>plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<link href="<%=sitepath%>css/animate.min.css" rel="stylesheet">
<link href="<%=sitepath%>css/style.min.css" rel="stylesheet">
<link href="<%=sitepath&adminPath%>css/adminstyle.css" rel="stylesheet">
<script src="<%=sitepath%>js/jquery.min.js"></script>
<script src="<%=sitepath&adminPath%>js/adminjs.js"></script>

<!--[if lte IE 9]>
<script src="<%=sitepath%>js/respond.min.js"></script>
<script src="<%=sitepath%>js/html5.js"></script>
<![endif]-->
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content">
<div class="ibox float-e-margins">
<div class="row row-lg">
<div class="col-md-6">
							<div class="panel">
								<div class="panel-heading">
									<h3 class="panel-title">分类管理</h3>
									<div class="panel-aj">
										<button type="button" class="btn-toggle-collapse"><i class="fa fa-chevron-down"></i></button>
										<button type="button" class="btn-remove"><i class="fa fa-times"></i></button>
									</div>
								</div>
<div class="panel-body">
<div class="panel-body no-padding">		
<div class="ibox-content">

<FORM name="" action="" id="sortlist" method="post">
            <div id="toolbar">
              <div class="col-sm-5">
                 <button onClick="location.reload()" class="btn btn-primary1" type="button"><i class="fa fa-refresh">　</i>刷新</button> 
                  <%if not isnul(Stype) then%> <button onClick="location.href='Sort_List.asp'" class="btn" type="button"><i class="fa fa-reply">　</i>返回</button><%end if%>  
              </div>
              <div class="col-sm-7 text-right">
                <button id="add" class="btn  btn-primary" type="button" onClick="opennew('sort_add.asp')"><i class="fa fa-plus">　</i>添加</button>        
                  </div>          
            </div>
            <table id="table"
           data-toggle="table"
           data-pagination="true"      
           data-id-field="id"    
           data-url="Sort_fun.asp?act=Sort_List"
           data-id-table="advancedTable"
           data-page-size="200"
           data-page-list="[200,1000,2000]">
              <thead>
                <tr>
                  <th class="tableid" data-field="state" data-checkbox="true"></th>
                  <th class="tabletype" data-field="id" >ID</th>
                  <th class="tabletitle" data-field="S_name" >中文名称</th>
                  <th class="tablename" data-field="S_enname">英文名称</th>
                  <th class="tabletype" data-field="S_type">类型</th>
                  <th class="tableurl" data-field="S_url">链接/短链接</th>                  
                  <th class="tableorder" data-field="S_order">排序</th>
                  <th class="tableonoff" data-field="S_onoff">状态</th>
                  <th class="tableedit text-right" data-field="S_edit">编辑</th>
                </tr>
              </thead>              
            </table>
          </FORM>

</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- End Panel Other -->

<div class="modal inmodal fade" id="myModal6" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span> </button>
        <h4 class="modal-title">移动分类</h4>
      </div>
      <div class="modal-body">
        <input name="nowsortid" id="nowsortid" value="" type="hidden" >
        <select class="form-control m-b" name="moveSortID" id="moveSortID">
        </select>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
        <button type="button" id="moveid" class="btn btn-primary">移动</button>
      </div>
    </div>
  </div>
</div>
<script>
$(function() {
    $("#moveid").click(function() {
        var moveID = $("#nowsortid").val();
        var moveSortID = $("#moveSortID").val();
        $.post("?act=moveid&moveID=" + moveID + "&moveSortID=" + moveSortID, function(data) {});
        $(".close").click();
        location.reload();
    });
    $("#back").click(function() {self.history.back(-1);})
    $("#table").on("click", (".open"), function() {
        var PID = $(this).text();
        $("." + PID).parent("td").parent("tr").slideToggle()
        $(this).toggleClass("active")
    })
})
	 var $table = $('#table'),
		 $remove = $('#remove');
 		 $move = $('#move');		 	
	 $(function () {
        $table.on('check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table', function () {
            $remove.prop('disabled', !$table.bootstrapTable('getSelections').length);
			$move.prop('disabled', !$table.bootstrapTable('getSelections').length);			
        });		
		$move.click(function(){
			var ids = $.map($table.bootstrapTable('getSelections'), function (row) {return row.id	 });	
			$("#nowsortid").val(ids);
			$.post("Sort_Fun.asp?act=Loadsort&sortid="+ids, function(result){$("#moveSortID").html("<option value='0'>一级分类</option>"+result); });			
		});
        $remove.click(function () {
            var ids = $.map($table.bootstrapTable('getSelections'), function (row) {return row.id});
			delsort(ids)
            $table.bootstrapTable('remove', {field: 'id',values: ids });
			setdisabled();
        });		
    });
	function setdisabled(){
			$remove.prop('disabled', true);
			$move.prop('disabled', true);			
			}

$("#table").on("blur","input",function(){
$this=$(this)	
 var colval=$this.val();
 var colplace=$this.attr('placeholder')
 var colid=$this.attr('id').split("-")[1];
 var colname=$this.attr('id').split("-")[0];
 	if(colname=="S_url" && colval.length>0 && colval!=colplace){
		colval=UpperFirstLetter(colval);
		$(".S_URL").each(function() { 	
            if($(this).attr('placeholder')==colval){layer.msg("短链接已被使用，请更换",{icon: 2});;colval=colplace; return false;}
        });
		$this.val(colval);
	} 
if (colval!=colplace){	
	 $.post("Sort_Fun.asp?act=saveid",{colval:colval,colid:colid,colname:colname},function(data){
		 if(data=="1")
		 {layer.msg('保存成功',{icon: 1,time: 1500});$this.attr('placeholder',colval);}
	 	else
		 {layer.msg(data,{icon: 2});$this.val(colplace)}
	 });
	}
});
</script> 
<script src="<%=sitepath%>js/klorofil-common.js"></script>
<script src="<%=sitepath%>js/bootstrap.min.js"></script> 
<script src="<%=sitepath%>plugins/bootstrap-table/bootstrap-table.min.js"></script> 
<script src="<%=sitepath%>plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script> 
<script src="<%=sitepath%>plugins/layer/layer.min.js"></script>
</body>
</html>
