{echo:JS::import('dialog?skin=brief');}
{echo:JS::import('dialogtools');}
{echo:JS::import('form');}
<form action="" method="post">
    <div class="tools_bar clearfix">
        <a class="icon-checkbox-checked icon-checkbox-unchecked" href="javascript:;" onclick="tools_select('id[]',this)" title="全选" data="true"> 全选 </a>
        <a  class="icon-remove-2" href="javascript:;" onclick="tools_submit({action:'{url:/content/tags_del}',msg:'删除后无法恢复，你真的删除吗？'})" title="删除"> 删除</a>
        <a class="icon-delicious" href="{url:/content/tags_list}"> 全部记录</a>
        <span class="fr"><a href='javascript:;' id="condition" class="icon-search" style="" > 筛选条件</a><input id="condition_input" type="hidden" name="condition" value="{$condition}"></span>
    </div>
    <table class="default" >
        <tr>
            <th style="width:30px">选择</th>
            <th style="width:70px">操作</th>
            <th >标签</th>
            <th style="width:80px">搜索数</th>
            <th style="width:100px">排序</th>
            <th style="width:60px">类型</th>    
        </tr>
            {query:name=tags order=is_hot desc,sort desc,num desc where= $where id=$obj page=1 desc }
            <tr><td style="width:30px"><input type="checkbox" name="id[]" value="{$item['id']}"></td>
                <td style="width:70px" class="btn_min"><div class="operat hidden"><a  class="icon-cog action" href="javascript:;"> 处理</a><div class="menu_select"><ul>
                    {if:$item['is_hot']==0}
                    <li><a class="icon-thumbs-up" href="javascript:tags_top({$item['id']},1);"> 置顶</a></li>
                    {else:}
                    <li><a class="icon-thumbs-up-2" href="javascript:tags_top({$item['id']},0);"> 取消置顶</a></li>
                    {/if}
                    <li><a class="icon-list-2" href="javascript:tage_sort({$item['id']});"> 排序</a></li>
                    <li> <a class="icon-remove-2" href="javascript:confirm_action('{url:/content/tags_del/id/$item[id]}')"> 删除</a></li>
                </ul></div></div> </td>
                <td >{$item['name']}</td><td style="width:80px">{$item['num']}</td><td style="width:100px">{$item['sort']}</td><td style="width:60px">{if:$item['is_hot']==1}<span class='red'><b>热门</b></span>{else:}<span class='gray'>普通</span>{/if}</td>
            </tr>
            {/query}
        </table>
</form>
<div class="page_nav">
    {echo:$obj->pageBar()}
</div>
<div id="sort-dialog" class="default" style="display:none;width:360px;">
   <form action="" method="post" class="form2" callback="tags_update">
      <input type="hidden" id="template_id" name="id" value="">
      <dl class="lineD">
          <dt>排序：</dt>
          <dd id="voucher_name"><input name="sort" pattern="int" class="small" id="tags-sort"> <label>必需为数字</label></dd>
      </dl>
      <dl>
          <dt></dt>
          <dd><button class="btn">设定</button></dd>
      </dl>
  </form>
</div>
<script type="text/javascript">
    var form =  new Form();
    $("#condition").on("click",function(){
        $("body").Condition({input:"#condition_input",okVal:'高级搜索',callback:function(data){tools_submit({action:'{url:/content/tags_list}',method:'get'});},data:{'name':{name:'标签'},'num':{name:'搜索数'},'sort':{name:'排序'},'is_hot':{name:'是否置顶',values:{0:'否',1:'是'}}
    }});
    });
    function tags_top(id,status)
    {
        var url = "{url:/content/tags_update}";
        $.get(url,{id:id,status:status},function(data){
            if(data['status']=='success'){
                art.dialog.tips("<p class='success'>修改成功。</p>");
                setTimeout("tools_reload()",2);
            }
            else art.dialog.tips("<p class='"+data['status']+"'>"+data['msg']+"</p>");
        },'json');
    }
    function tage_sort(id)
    {
        $("#tags-sort").data("id",id);
        $("#tags-sort").val('');
        art.dialog({id:'tags-dialog',title:'排序',content:document.getElementById('sort-dialog'),width:400});
    }
    function tags_update(e)
    {
        var id =  $("#tags-sort").data("id");
        var sort = $("#tags-sort").val();
        var url = "{url:/content/tags_update}";
        if(!e){
            $.get(url,{id:id,sort:sort},function(data){
                if(data['status']=='success'){
                    art.dialog.tips("<p class='success'>排序成功。</p>");
                    setTimeout("tools_reload()",2);
                }else{
                    art.dialog.tips("<p class='"+data['status']+"'>"+data['msg']+"</p>");
                }
            },'json');
        }
        return false;
    }

</script>
