Skip to content

Commit

Permalink
update letter
Browse files Browse the repository at this point in the history
  • Loading branch information
Smilence1024 committed Mar 17, 2017
1 parent 8243f2d commit b314f87
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 33 deletions.
35 changes: 3 additions & 32 deletions src/main/resources/static/js/letter.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
var page = 1;
$(function(){
reload();
var loadingFlag = true;
$(window).scroll(function(){
if ($(window).scrollTop() == $(document).height() - $(window).height()) {
if($("#letter").length >= 1){
if(loadingFlag){
loadingFlag = false;
$('#loadingStandard').show();
loadMore();
$('#loadingStandard').hide();
loadingFlag = true;
}
}
}
});
});

function loadMore(){
$.ajax({
Expand All @@ -31,6 +14,9 @@ function loadMore(){
},
success: function(letters){
listLetter(letters);
if(letters.length > 0){
reload();
}
page++;
}
});
Expand Down Expand Up @@ -88,7 +74,6 @@ function listLetter(letters){
letterList = letterList + item;
}
$("#letterList").append(letterList);
reload();
}

// 发送私信
Expand Down Expand Up @@ -141,17 +126,3 @@ function sendLetter(type,pid,obj){
});
}

function reload(){
$(".timeline li").each(function(){
var _this = $(this);
_this.find(".table-grid .btn").click(function(){
if(_this.find(".collapse").hasClass('in')){
_this.find(".collapse").removeClass('in')
}else{
_this.find(".collapse").addClass('in')
var rep = "@"+_this.find(".m0 .text-muted .send-user-name").html()+" ";
_this.find(".form-control").focus().val(rep);
}
});
});
}
35 changes: 34 additions & 1 deletion src/main/resources/templates/notice/letterme.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ <h3>私信我的</h3>
<div class="input-group">
<input type="text" class="form-control" required="required" placeholder="输入回复..." />
<span class="input-group-btn">
<button type="submit" th:onclick="'sendLetter(\'reply\',\''+${letter.id}+'\',this);'" class="btn btn-default" th:value="${letter.id}">发送</button>
<button type="submit" th:onclick="'sendLetter(\'reply\',\''+${letter.id}+'\',this);'" class="btn btn-default" >发送</button>
</span>
</div>
</form>
Expand All @@ -61,4 +61,37 @@ <h3>私信我的</h3>
</div>
</section>
</body>
<script type='text/javascript' th:inline="javascript">
$(function(){
reload();
var loadingFlag = true;
$(window).scroll(function(){
if ($(window).scrollTop() == $(document).height() - $(window).height()) {
if($("#letter").length >= 1){
if(loadingFlag){
loadingFlag = false;
$('#loadingStandard').show();
loadMore();
$('#loadingStandard').hide();
loadingFlag = true;
}
}
}
});
});
function reload(){
$(".timeline li").each(function(){
var _this = $(this);
_this.find(".table-grid .btn").click(function(){
if(_this.find(".collapse").hasClass('in')){
_this.find(".collapse").removeClass('in')
}else{
_this.find(".collapse").addClass('in')
var rep = "@"+_this.find(".m0 .text-muted .send-user-name").html()+" ";
_this.find(".form-control").focus().val(rep);
}
});
});
}
</script>
</html>

0 comments on commit b314f87

Please sign in to comment.