<%@ 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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <!--#include file = "../Css/userCssEdit.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 : '../Editor/UserEditor/aspnet/upload_json.ashx',
		    fileManagerJson : '../Editor/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>
</head>
<body>
    <form id="form1" runat="server">
    <div class="edit-func-box func-box">
        <div class="hd b">推送至微课公众号</div>
        <div class="bd">
            <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="推送至微课号" CssClass="ckb-txt" onclick="showweikeID();" />
                    <asp:TextBox ID="txtWeikeID" runat="server" CssClass="input-txt" Style="display: none;"></asp:TextBox>
                </td>
                </tr>
                <tr>
                    <th>
                        标题：
                    </th>
                    <td>
                        <asp:TextBox ID="intactTitle" runat="server" CssClass="input-txt input-txt3" MaxLength="20" ></asp:TextBox>&nbsp;&nbsp;<span class="lgrey">标题不超过20个字</span>
                    </td>
                </tr>
                <tr>
                    <th>
                        封面：
                    </th>
                    <td>
                        <div class="addpicnews-div fn-fl">
                        <img alt="" src="../images/uploadfiles/default.jpg" runat="server" id="pho" class="fn-fl 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-txt"></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-txt input-txt3" ReadOnly="true" Visible="false"></asp:TextBox>
                    </td>
                </tr>
            </table>
        </div>
        <div class="ft">
            <div class="action-field txt-c">
                <asp:Button ID="ok" CssClass="btn" runat="server" Text="推 送" OnClientClick="return checkAll();" onclick="ok_Click" ></asp:Button>
                &nbsp;&nbsp;&nbsp;&nbsp;
                <input type="button" class="btn" value="关 闭" onclick="parent.$.fancybox.close();" />&nbsp;
                <p style="padding-top:10px;"><asp:Label ID="labMsg" runat="server" Text="" ForeColor="Red"></asp:Label></p>
            </div>
            
        </div>
        <input id="imageName" type="hidden" name="imageName" runat="server" value="" />
    </div>
    </form>
</body>
</html>
