<div class="current-location">
    <ul>
        <li class="left"><i class="glyphicon glyphicon-home"></i><a href="javascript:void(0)" onclick="location.href=location.href">插件管理</a></li>
        <li class="right"><a href="javascript:void(0)" onclick="LoadData()" title="刷新"><span class="glyphicon glyphicon-refresh"></span></a></li>
    </ul>
</div>
<style>
    .lb-enabled-0 {
        color: #999
    }
</style>
<div class="main">
    <ul class="navTabs">
        <li data-tab-params="tabName:'全部',tabValue:'',tabValueObjName:'#enabled'"></li>
        <li data-tab-params="tabName:'已启用',tabValue:'1',tabValueObjName:'#enabled'"></li>
        <li data-tab-params="tabName:'未启用',tabValue:'0',tabValueObjName:'#enabled'"></li>
    </ul>
    <table class="tb-head" cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td align="right">
                <div class="form-group">
                    <div class="controls form-inline form-group-sm">
                        <select id="s_field" name="s_field" class="btn-xs ui-queryString ui-setName form-control">
                            <option value="name">插件名称</option>
                            <option value="author">插件作者</option>
                            <option value="introduction">插件简介</option>
                        </select>
                        <input type="hidden" name="enabled" id="enabled" class="ui-queryString"/>
                        <input type="text" class="ui-queryString ui-keyword  form-control" maxlength="20" style="width:140px" placeholder="输入关键词">
                        <button type="button" class="btn btn-default btn-sm ui-queryString-search">搜索</button>
                    </div>
                </div>
            </td>
        </tr>
    </table>
    <div class="clearfix">
        <div class="row clearfix" id="tb_list" style="margin-bottom:15px">
            <div class="col-lg-3 col-md-3 item list-template-item" id="item_{index}">
                <div class="panel panel-default">
                    <div class="panel-heading clearfix">
                        <h5 class="pull-left"><strong>{name}</strong></h5>
                        <h5 class="pull-right"><span class="label sp_state lb-enabled-{enabled}"></span></h5>
                    </div>
                    <div class="panel-body clearfix">
                        <p>作者：{author}</p>
                        <p>版本：{Version}</p>
                        <p>
                            安装时间：{InstallDate}
                        </p>
                        <p class="clearfix" style="height:100px;overflow:hidden;">
                            {Introduction}
                            <h5 class="pull-left"><a class="label label-primary" href="{url}" target="_blank">详情</a></h5>
                        </p>
                        <p>&nbsp;</p>
                        <div class="btn-group btn-group-sm right" role="group" aria-label="...">
                            <button class="btn btn-default btn-sm ui-dialog stop-{enabled}" data-custom-params="title:'插件更新',url:'@Url.Action("Index","PluginUpgrade")?pluginName={pluginName}',width:'750px',height:'80%'">更新</button>
                            <button class="btn btn-default btn-sm ui-dialog stop-{enabled}" data-custom-params="title:'插件关闭',url:'@Url.Action("Set")?act=close&pluginName={pluginName}',width:'750px',height:'380px'">关闭</button>
                            <button class="btn btn-success btn-sm ui-dialog open-{enabled}" data-custom-params="title:'插件开启',url:'@Url.Action("Set")?act=open&pluginName={pluginName}',width:'750px',height:'420px'">开启</button>
                            <button class="btn btn-default btn-sm ui-dialog unload-{enabled}" data-custom-params="title:'插件卸载',url:'@Url.Action("Set")?act=uninstall&pluginName={pluginName}',width:'750px',height:'380px'">卸载</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(".navTabs").children().InitTab(function () { LoadData() }); //初始化选项卡，并设置回调函数为LoadData()
    //绑定数据
        var $container = $('#tb_list');
    function LoadedInit()
    {
        $(".lb-enabled-1").text("已启用").addClass("label-success");
        $(".lb-enabled-0").text("已关闭").addClass("label-default");
        $(".stop-0").hide();
        $(".open-1").hide();
        $(".unload-1").hide();
        $(".install-date-0").remove();
    }


    function LoadData() {
        var url = "@Url.Action("PageListData")";
        $container.ListBind({ url: url, callBack: "LoadedInit" });
    }
    LoadData();


    function CallBack()
    {
        var url = "@Url.Action("PageListData")";
        $("#tb_list").ListBind({ url: url, callBack: "RestartApplication" });
    }

    function RestartApplication()
    {
        LoadedInit();
        var url = "@Url.Action("RestartApplication","Default")";
        var Data = Ajax({ type: "post", async: false, url: url });
    }

</script>
