...
|
...
|
@@ -5,6 +5,7 @@ |
|
|
*/
|
|
|
|
|
|
var $ = require('jquery'),
|
|
|
Hammer = require('hammer'),
|
|
|
ellipsis = require('mlellipsis'),
|
|
|
lazyLoad = require('yoho.lazyload');
|
|
|
|
...
|
...
|
@@ -46,15 +47,21 @@ function setLazyLoadAndMellipsis($infos) { |
|
|
* @params $container 逛资讯列表容器
|
|
|
*/
|
|
|
function initInfosEvt($container) {
|
|
|
$container.delegate('.like-btn', 'tap', function(e) {
|
|
|
var $likeBtn = $(e.currentTarget),
|
|
|
$info = $likeBtn.closest('.guang-info'),
|
|
|
opt = 'ok';
|
|
|
var cHammer = new Hammer($container[0]);
|
|
|
|
|
|
cHammer.on('tap', function(e) {
|
|
|
var $this = $(e.target),
|
|
|
opt = 'ok',
|
|
|
$likeBtn,
|
|
|
$info;
|
|
|
|
|
|
$likeBtn = $this.closest('.like-btn');
|
|
|
if ($likeBtn.length > 0) {
|
|
|
if ($likeBtn.hasClass('like')) {
|
|
|
opt = 'cancel';
|
|
|
}
|
|
|
|
|
|
$info = $this.closest('.guang-info');
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/guang/opt/praiseArticle',
|
...
|
...
|
@@ -76,6 +83,7 @@ function initInfosEvt($container) { |
|
|
tip.show('网络断开连接了~');
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
setLazyLoadAndMellipsis($container.find('.guang-info'));
|
...
|
...
|
@@ -85,6 +93,8 @@ function initInfosEvt($container) { |
|
|
* 资讯LoadMore
|
|
|
*/
|
|
|
function loadMore($container, opt) {
|
|
|
var num;
|
|
|
|
|
|
if (searching) {
|
|
|
return;
|
|
|
}
|
...
|
...
|
@@ -93,18 +103,21 @@ function loadMore($container, opt) { |
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (opt.page === 0) {
|
|
|
if (opt.page === 1) {
|
|
|
|
|
|
//显示loading
|
|
|
loading.showLoadingMask();
|
|
|
}
|
|
|
|
|
|
num = $container.find('.guang-info').length;
|
|
|
searching = true;
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: ' /guang/index/page',
|
|
|
data: opt,
|
|
|
success: function(data) {
|
|
|
var $newItems;
|
|
|
|
|
|
if (data === ' ') {
|
|
|
opt.end = true;
|
|
|
searching = false;
|
...
|
...
|
@@ -117,9 +130,15 @@ function loadMore($container, opt) { |
|
|
}
|
|
|
$container.append(data);
|
|
|
|
|
|
setLazyLoadAndMellipsis($container.find('.guang-info'));
|
|
|
if (num > 0) {
|
|
|
$newItems = $container.find('.guang-info:gt(' + (num - 1) + ')');
|
|
|
} else {
|
|
|
$newItems = $container.find('.guang-info');
|
|
|
}
|
|
|
|
|
|
setLazyLoadAndMellipsis($newItems);
|
|
|
|
|
|
if (opt.page === 0) {
|
|
|
if (opt.page === 1) {
|
|
|
loading.hideLoadingMask();
|
|
|
}
|
|
|
|
...
|
...
|
|