-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3274a09
commit e5eab73
Showing
5 changed files
with
191 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
# mip-233-newsmore | ||
|
||
分页加载新闻插件 | ||
|
||
标题|内容 | ||
----|---- | ||
类型|业务,广告 | ||
支持布局|N/S | ||
所需脚本|https://mipcache.bdstatic.com/static/v1/mip-233-newsmore/mip-233-newsmore.js | ||
|
||
## 示例 | ||
|
||
``` html | ||
<mip-233-newsmore data-page="2" data-maxpage="10" data-filename="162929237"> | ||
<div class="news-content mid" showmorebox> | ||
<p>童年是美好的,它犹如一杯加了糖的柠檬汁,酸甜可口,回味无穷。童年的回忆又是美妙的,它就似一幅流光溢彩的画卷,将许许多多有趣的、好玩的事情绘入我的脑海,时常一幕幕的闪现。其中两个小片断,每每想起,内心就会不由自主升起一股浓浓的笑意。 | ||
孩提时代,模仿是孩子们的天性,当然我也不例外。我三岁多的时候,经常见爸爸上厕所时不是拿着书就是带着报。我不明白其中的奥妙,但也好去模仿。每次上厕所时,也装模做样的拿着报纸进去,出来的时候又照样拿出来。爸爸发现我的这一举动后,感到很奇怪,因为那时候,我还不认识几个字。他就在我上厕所的时候,偷偷地拉开门,然后就哈哈大笑起来,笑的眼泪都快出来了。因为他看见我老老实实地坐在马桶上,并没有看报读书,而是把报纸放在墙边。原来,这是我观察爸爸后的“模仿秀”。 | ||
</p> | ||
|
||
<p>俗话说,“一天内,人有三迷”。平常,我的小脑袋瓜也有“断电”的时候。记得有一次早上,起床有点晚,妈妈催促我赶快穿衣吃饭去上学,并叮嘱我穿好毛衣。由于时间紧,我手忙脚乱地穿衣收拾东西。但是,怎么也找不到我的毛衣,急得像热锅上的蚂蚁—团团转。我赶快向妈妈求救,让她帮我也找找毛衣。妈妈走过来后,装作很生气的样子,用手在我的小屁股上拍了一巴掌,说道:“你这孩子怎么搞的,都不长一点脑子,看看自己身上是什么。”我一低头,脸一下子就红到了耳根。原来,毛衣已经在我慌乱时穿在了身上,而我还在“骑驴找驴”。</p> | ||
|
||
<p>童年是充满阳光的,它让我享受了世间最好的关爱;童年是五颜六色的,它使我的回忆绚丽多彩;童年又是丰富有趣的,它给了我无穷的快乐。</p> | ||
</div> | ||
|
||
<div class="button-div" showmorebtn><span href="javaScript:;" class="more-button">展开加载全文<i></i></span></div> | ||
</mip-233-newsmore> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* @file 分页加载新闻插件 | ||
* @author 233 程序部 | ||
*/ | ||
define(function (require) { | ||
var $ = require('zepto'); | ||
var customElem = require('customElement').create(); | ||
// build 方法,元素插入到文档时执行,仅会执行一次 | ||
customElem.prototype.build = function () { | ||
var element = this.element; | ||
var page = parseInt($(element).attr('data-page'), 10); | ||
var maxpage = parseInt($(element).attr('data-maxpage'), 10); | ||
var filename = $(element).attr('data-filename'); | ||
function newHtml(obj, filename, page) { | ||
$.ajax({ | ||
type: 'get', | ||
url: filename + '-' + page + '.htm?tim=' + new Date().getTime(), | ||
scriptCharset: 'utf-8', | ||
dataType: 'html', | ||
success: function (data) { | ||
if (data) { | ||
$(element).find('.news-content').html($(element).find('.news-content').html() + data); | ||
obj.attr('data-page', ++page); | ||
} | ||
}, | ||
error: function (data) { | ||
return false; | ||
} | ||
}); | ||
} | ||
$(element).find('.more-button').click(function () { | ||
if (page <= maxpage) { | ||
newHtml($(this), filename, page); | ||
} else { | ||
$(this).remove(); | ||
} | ||
}); | ||
}; | ||
return customElem; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "mip-233-newsmore", | ||
"version": "1.0.0", | ||
"description":"分页加载新闻插件", | ||
"author": { | ||
"name": "newsmore", | ||
"email": "[email protected]", | ||
"url": "www.233.com" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters