<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PushWeike.aspx.cs" Inherits="Web.User.PushWeike" %>

<!DOCTYPE html>
<!--[if lt IE 9]><html class="lte-ie8"><![endif]-->
<!--[if gt IE 8]><!-->
<html>
<!--<![endif]-->
<head>
    <title>推送至微课公众号</title>
    <!--#include file="../Css/head.htm"-->
    <!--#include file = "../Css/userCssEdit.htm" -->
    <style>
        .nsy-wechatmsg-wrap {
            float: left;
            width: 300px;
        }

            .nsy-wechatmsg-wrap + div {
                margin-left: 300px;
            }

        .nsy-wechatmsg-item {
            position: relative;
            padding: 10px;
            border: 1px solid #d5d5d5;
            margin-top: -1px;
            cursor: pointer;
        }

        .nsy-weikemsg-item {
            margin-bottom: 10px;
        }

        .nsy-wechatmsg-item > .first {
            height: 125px;
        }

        .nsy-wechatmsg-item > .other {
            height: 70px;
        }

        .nsy-wechatmsg-content {
            position: relative;
        }

        .nsy-wechatmsg-img {
            overflow: hidden;
            background-color: #999;
            background-repeat: no-repeat;
            background-size: cover;
            background-position: center center;
        }

        .nsy-wechatmsg-item > .first .nsy-wechatmsg-content,
        .nsy-wechatmsg-item > .first .nsy-wechatmsg-img {
            height: 125px;
            line-height: 125px;
        }

        .nsy-wechatmsg-item > .other .nsy-wechatmsg-content {
            height: 70px;
        }

        .nsy-wechatmsg-item > .other .nsy-wechatmsg-img {
            float: right;
            width: 70px;
            height: 70px;
            margin-left: 15px;
            line-height: 70px;
        }

        .nsy-wechatmsg-title {
            font-size: 14px;
            font-weight: normal;
            overflow: hidden;
        }

        .nsy-wechatmsg-item > .first .nsy-wechatmsg-title {
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            height: 28px;
            padding: 0 10px;
            line-height: 28px;
            color: #fff;
            background-color: rgba(0,0,0,.5);
        }

        .nsy-wechatmsg-item > .other .nsy-wechatmsg-title {
            float: left;
            width: 112px;
            max-height: 48px;
            margin-top: 6px;
            line-height: 24px;
        }

        .nsy-wechatmsg-img {
            text-align: center;
            vertical-align: middle;
            color: #fff;
        }

            .nsy-wechatmsg-img .default {
                vertical-align: middle;
            }

        .nsy-wechatmsg-cover {
            display: none;
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            height: 40px;
            padding: 0 10px;
            line-height: 40px;
            color: #fff;
            background-color: rgba(0,0,0,.3);
        }

        .nsy-wechatmsg-item > div:hover .nsy-wechatmsg-cover {
            display: block;
        }

        .nsy-wechatmsg-icon {
            margin: 0 10px;
            color: #fff;
        }

            .nsy-wechatmsg-icon:hover {
                color: #fff;
            }

        .nsy-wechatmsg-add {
            display: block;
            border: 1px dotted #d5d5d5;
            line-height: 100px;
            text-align: center;
            color: #eee;
        }

            .nsy-wechatmsg-add i {
                vertical-align: middle;
            }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div class="main-content-inner">
            <div class="breadcrumbs" id="breadcrumbs">

                <ul class="breadcrumb">
                    <li>
                        <i class="ace-icon fa fa-home home-icon"></i>
                        <a href="#">首页</a>
                    </li>

                    <li class="active">推送至微课</li>
                </ul>
                <!-- /.breadcrumb -->
            </div>
            <div class="page-content">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="nsy-wechatmsg-wrap">
                            <div class="nsy-wechatmsg">
                                <asp:Repeater ID="list" runat="server" OnItemCommand="list_ItemCommand">
                                    <HeaderTemplate>
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                        <div class="nsy-wechatmsg-item nsy-weikemsg-item" runat="server">
                                            <div class="first">
                                                <div class="nsy-wechatmsg-content">
                                                    <h3 class="nsy-wechatmsg-title"><%# Eval("intactTitle")%></h3>
                                                    <div class="nsy-wechatmsg-img"  style='<%# "background-image: url("+ Eval("imageUrl")+");" %>'>
                                                        <i class="default fa fa-picture-o fa-3x"></i>
                                                    </div>
                                                </div>
                                                <div class="nsy-wechatmsg-cover">
                                                    <%--<a class="nsy-wechatmsg-icon js-del pull-right" title="删除" href="javascript:void(0);">
                                                        <i class="fa fa-trash"></i>
                                                    </a>--%>
                                                    <asp:LinkButton ID="delete" runat="server" commandname="delete"  commandargument='<%# Eval("pkid")%>' class="nsy-wechatmsg-icon js-del pull-right"><i class="fa fa-trash"></i></asp:LinkButton>
                                                    <asp:LinkButton ID="edit" runat="server" commandname="edit"  commandargument='<%# Eval("newsid")%>' class="nsy-wechatmsg-icon  pull-right"><i class="ace-icon fa fa-arrow-right icon-on-right"></i></asp:LinkButton>
                                                </div>
                                            </div>
                                        </div>
                                    </ItemTemplate>
                                    <FooterTemplate></FooterTemplate>
                                </asp:Repeater>

                            </div>
                            <hr />

                        </div>
                        <div class="row">
                            <div class="col-xs-12">
                                <div class="alert alert-warning" role="alert">注意：点击左边列表中的小箭头指定要推送的信息（每次只限推送一条）</div>
                                <table class="edit-table" id="Table1">
                                    <tr>
                                        <th style="width: 100px;">微课公众号：
                                        </th>
                                        <td>
                                            <asp:Label ID="lbPublicName" runat="server" Text=""></asp:Label>
                                            <asp:HiddenField ID="hfidstr" runat="server" />
                                            &nbsp;&nbsp;
                    <asp:CheckBox ID="chbWeikeID" runat="server" Text="推送至微课号" onclick="showweikeID();"  ToolTip="如果此处指定了某个微课号，那么本次仅向此号码推送" />
                                            <asp:TextBox ID="txtWeikeID" runat="server" CssClass="input-md" Style="display: none;"  ToolTip="如果此处指定了某个微课号，那么本次仅向此号码推送" ></asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>标题：
                                        </th>
                                        <td>
                                            <asp:TextBox ID="intactTitle" runat="server" CssClass="input-md w3" MaxLength="20"></asp:TextBox>&nbsp;&nbsp;<span class="lgrey">标题不超过20个字</span>
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>封面：
                                        </th>
                                        <td>
                                            <div class="addpicnews-div pull-left">
                                                <img alt="" src="../images/uploadfiles/default.jpg" runat="server" id="pho" class="pull-left img" width="220" height="160" />
                                            </div>
                                            <p class="fn-pt30">
                                                <a id="uploadimg" href="javascript:void(0);" class="blue">上传图片</a>
                                            </p>
                                            <p class="fn-pt30">
                                                <span class="lgrey">封面若未上传，则会使用默认封面</span>
                                            </p>
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>摘要：
                                        </th>
                                        <td>
                                            <asp:TextBox ID="tbDescript" runat="server" Width="400px" TextMode="MultiLine" Height="90px" MaxLength="100" CssClass="input-md"></asp:TextBox>
                                            <p>
                                                <span class="lgrey">摘要不超过100个字</span>
                                            </p>
                                        </td>
                                    </tr>
                                    <tr style="display: none;">
                                        <th>正文链接：
                                        </th>
                                        <td>
                                            <asp:TextBox ID="tburl" runat="server" CssClass="input-md w3" ReadOnly="true" Visible="false"></asp:TextBox>
                                        </td>
                                    </tr>
                                </table>
                                

                                <input id="imageName" type="hidden" name="imageName" runat="server" value="" />
                            </div>
                        </div>
                        <div class="action-field text-center">
                                    <asp:Button ID="ok" CssClass="btn btn-sm btn-primary" runat="server" Text="推 送" OnClientClick="return checkAll();" OnClick="ok_Click"></asp:Button>
                                    &nbsp;&nbsp;&nbsp;&nbsp;
                <input type="button" class="btn btn-sm btn-primary" value="关 闭" onclick="parent.$.fancybox.close();" />&nbsp;
                <p style="padding-top: 10px;">
                    <asp:Label ID="labMsg" runat="server" Text="" ForeColor="Red"></asp:Label>
                     <p> <asp:Label ID="labNewsid" runat="server" Text="" Visible="false"></asp:Label></p>
                </p>
                                </div>
                    </div>
                </div>
            </div>
        </div>
        <!--#include file="../Css/foot.htm"-->
        <script type="text/javascript">

            function checkAll() {
                //点击推送按钮时，将推送显示信息设置为空
                if (document.getElementById("chbWeikeID").checked == true) {
                    if (confirm("您确认要推送至微课号吗？")) {
                        var itit1 = document.getElementById("intactTitle").value;
                        var descript1 = document.getElementById("tbDescript").value;
                        var itit2 = document.getElementById("txtWeikeID").value;
                        if (itit1 == "") {
                            alert("标题不能为空!");
                            return false;
                        }
                        if (descript1 == "") {
                            alert("摘要不能为空!");
                            return false;
                        }
                        if (itit2 == "") {
                            alert("微课号不能为空!");
                            return false;
                        }
                        return true;
                    }
                    else {
                        return false;
                    }
                }
                else {
                    if (confirm("您确认要推送至微课公众号吗？")) {
                        var itit = document.getElementById("intactTitle").value;
                        var descript = document.getElementById("tbDescript").value;
                        if (itit == "") {
                            alert("标题不能为空!");
                            return false;
                        }
                        if (descript == "") {
                            alert("摘要不能为空!");
                            return false;
                        }
                        return true;
                    }
                    else {
                        return false;
                    }
                }

            }

            KindEditor.ready(function (K) {
                var editor = K.editor({
                    uploadJson: '../Wpedt/UserEditor/aspnet/upload_json.ashx',
                    fileManagerJson: '../Wpedt/UserEditor/aspnet/file_manager_json.ashx',
                    allowFileManager: true
                });

                K('#uploadimg').click(function () {
                    editor.loadPlugin('zdyimage', function () {
                        editor.plugin.zdyimageDialog({
                            zdyimageUrl: K('#imageName').val(),
                            clickFn: function (url) {
                                K('#imageName').val(K.formatUrl(url, 'domain'));
                                editor.hideDialog();
                                change();//加载预览图片
                            }
                        });
                    });
                });

            });

            function change() {
                var arr = $("#imageName").val();
                if (arr != "") {
                    $("#pho").attr('src', arr);
                }
            }

            //列表批量操作前检查选中行并读取id,title字符串 （ isConfirm：true|false,是否提示）
            function WeikeSelectCheck(ctlName, isConfirm) {
                var objs = document.getElementById(ctlName);
                var j = 0;
                var idstr = "";
                if (objs != null) {
                    if (objs.rows[0].cells[0].children[0].children.length > 0) {
                        for (i = 0; i < objs.rows[0].children.length; i++) {

                            if (objs.rows[0].cells[i].children[0].children[0].checked == true) {
                                idstr = idstr + objs.rows[0].cells[i].children[0].attributes["ListValue"].nodeValue + ",";
                                j += 1;
                            }

                        }
                    }
                    else {
                        alert("已经发送成功！为防止误操作导致重复推送，请关闭当前页面后再操作。");
                        return false;
                    }
                    document.getElementById("hfidstr").value = idstr;

                }
                if (j > 0) {
                    if (isConfirm) {
                        return confirm("您确认要推送至这(" + j + ")条选中的公众号吗？");
                    }
                    else {
                        return true;
                    }
                } else {
                    alert("注意：请选择公众号！");
                    return false;
                }
            }

            // 关闭弹出层 刷新栏目设置
            function divClose() {
                parent.$.fancybox.close();
                //parent.jQuery.triggerSelect();
                //parent.location="manageNews.aspx";
            }

            function delayClose() {
                //setTimeout("divClose()",3000);
            }

            //显示推送微课号
            function showweikeID() {
                if (document.getElementById("chbWeikeID").checked == true) {
                    document.getElementById("txtWeikeID").style.display = "inline-block";
                }
                else {
                    document.getElementById("txtWeikeID").style.display = "none";
                }
            }

            //判断页面是否加载完毕
            document.onreadystatechange = function () {
                //当页面加载状态为完全结束时进入 
                if (document.readyState == "complete") {
                    var editult = document.getElementById("chbWeikeID");
                    if (editult.checked == true) {
                        document.getElementById("txtWeikeID").style.display = "";
                    }
                }
            }
    </script>
    </form>
    <script>
        var items = $(".nsy-wechatmsg-item"),
        item_num = $(".nsy-wechatmsg-item").length;
        if ($(".nsy-wechatmsg-img").css("background-image") != "none") {
            $(".nsy-wechatmsg-img").find(".default").hide();
        }

        $(".js-del").click(function () {
            $(this).parents(".nsy-wechatmsg-item").remove();
            lintReset();
        });

    </script>
</body>
</html>
