<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>我的私信<?php echo V('-:tpl/title');?></title>
<link href="<?php echo W_BASE_URL;?>css/base.css" rel="stylesheet" type="text/css" />
<link href="<?php echo W_BASE_URL;?>css/skin_<?php echo SITE_SKIN_TYPE;?>/skin.css" rel="stylesheet" type="text/css" />
</head>
<body id="messages">
	<div id="wrapper">
    <!-- header -->
    <?php include APP::tplFile('header');?>
    <!-- end header -->
        <div id="container">
        	<div class="sidebar">
            	<?php include APP::tplFile('intro');?>
                <?php include APP::tplFile('user_menu');?>
            </div>
            <div class="main">
            	<div class="title-box nobottom-line">
                    <h3><a href="javascript:;" id="sndMsgBtn" class="general-btn"><span>发私信</span></a>我的私信</h3>
                </div>
				<?php if (empty($list)):?>
					<div class="default-tips">
						<div class="tips-icon all-bg"></div>
						<p>还没收到任何私信！</p>
					</div>
				<?php else:?>
					<div class="comment-list all-comment message-list">
						<ul>
							<?php foreach ($list as $item):?>
							<li id="m<?php echo $item['id'];?>">
								<div class="<?php if ($item['sender']['id'] == $userinfo['id']):?>sendbyme <?php endif;?>message-part">
									<div class="user-pic">
										<a href="<?php if ($item['sender']['id'] == $userinfo['id']):?><?php echo URL('index');?><?php else:?><?php echo URL('ta',array('id' => $item['sender']['id']));?><?php endif;?>"><img src="<?php echo APP::F('profile_image_url', $item['sender']['profile_image_url']);?>" alt="" /></a>
									</div>
									<div class="comment-c">
										<p class="c-info">
										<?php if ($item['sender']['id'] == $userinfo['id']):?>
											<a href="<?php echo URL('index');?>"> 我</a>发送给<a href="<?php  echo URL('ta',array('id' => $item['recipient']['id']));?>"><?php echo $item['recipient']['screen_name'];?></a>
										<?php else:?>
											<a href="<?php  echo URL('ta',array('id' => $item['sender']['id']));?>"><?php echo $item['sender']['screen_name'];?></a>
										<?php endif;?>
										<?php echo APP::F('format_text', $item['text']);?>  (<?php echo APP::F('format_time', $item['created_at']);?>) </p>
										<div class="c-for">
											<?php if ($item['sender']['id'] != $userinfo['id']):?>
											<a class="reply-icon icon-bg" href="javascript:;" rel="<?php echo $item['sender']['screen_name']?>,<?php echo $item['sender']['id'];?>">回复</a>
											<?php endif;?>
											<a class="del-icon icon-bg" style="display:none;" href="javascript:;">删除</a>
										</div>
									</div>
								</div>
							</li>
							<?php endforeach;?>
						</ul>

						<div class="list-footer">
							<div class="page">
								<?php echo $makePage;?>
							</div>
							<a class="gotop-icon icon-bg" href="#">返回顶部</a>
						</div>
					</div>
				<?php endif;?>
            </div>
        </div>
        <!-- footer -->
		<?php include APP::tplFile('footer');?>
        <!-- end footer -->
    </div>
<script type="text/javascript" src="<?php echo W_BASE_URL;?>js/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo W_BASE_URL;?>js/common.js"></script>
<script type="text/javascript" src="<?php echo W_BASE_URL;?>js/ui.js"></script>
<script type="text/javascript" src="<?php echo W_BASE_URL;?>js/msgs.js"></script>
<script>
var XWEIBO = {uid: '<?php echo $userinfo["id"];?>', emotions: <?php echo json_encode(V('-:sinaWeiboEmotions'));?>, autoshow: '<?php echo  V('-:userConfig/user_newfeed');?>', tipshow: '<?php echo  V('-:userConfig/user_newmsg');?>'};

$(document).ready(function() {
  // 发私信按钮点击
  $('#sndMsgBtn').click(function(e){
    e.preventDefault();
    XWB.MSGS.showPopup();
  });

  XWB.bindSearch($('#search'), $('#searchSubmit'));

  // mouseover 显示 删除
  $('.comment-list > ul > li').hover(function(e){
    $(this).find('a.del-icon').show();
  }, function(e){
    $(this).find('a.del-icon').hide();
  });

  // 删除, 回复
  $('.comment-list').click(function(e){
    var el = $(e.target), mid;
    // 删除
    if(el.hasClass('del-icon')){
      var li = el.tagUp('LI');
      mid = li.attr('id').substr(1);
      XWB.confirm({
        title:'提示',
        msg : '确定要删除该条私信？',
        focus:'enter'
      }, function(){
        XWB.MSGS.delMsg(mid, function(ret){
          if(ret.rst){
            location.reload();
          }
        });
      });
      e.preventDefault();
    }
    // 回复
    else if(el.hasClass('reply-icon')){
      mid = el.tagUp('LI').attr('id').substr(1);
      var rel = el.attr("rel").split(',');
      XWB.MSGS.reply(rel[0], rel[1]);
      e.preventDefault();
    }
  });

      $('#container div.user-intro strong').substrByWidth(105);

    setTimeout(function(){
		XWB.notifyChecker.start();
	}, 3000);
});
</script>

</body>
</html>

