-
Notifications
You must be signed in to change notification settings - Fork 458
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from phpsupai/master
帝国cms 整合包
- Loading branch information
Showing
3 changed files
with
193 additions
and
0 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,85 @@ | ||
@@ -0,0 +1,38 @@ | ||
# mip-emcs | ||
mip-ecms 帝国cms,整合包主要包括ecms中调用的js如点赞,阅读量,评论等。 | ||
|
||
标题|内容 | ||
----|---- | ||
类型|定制 | ||
支持布局|N/S | ||
所需脚本|https://mipcache.bdstatic.com/static/v1/mip-ecms/mip-ecms.js | ||
|
||
## 示例1 | ||
|
||
### 5 内容页点赞。 | ||
```html | ||
<mip-ecms-zan ecms-classid="1" ecms-id="1" ecms-type="5" class="favorite"> | ||
<span class="count">点赞数</span> | ||
</mip-ecms-zan> | ||
``` | ||
## 示例2 | ||
|
||
### 评论验证码点击刷新 | ||
```html | ||
<mip-img src="验证码URL" name="KeyImg" id="KeyImg" align="bottom" alt="看不清楚,点击刷新"></mip-img> | ||
``` | ||
## 示例3 | ||
|
||
### 回滚页面顶部 | ||
```html | ||
<div class="scroll" id="scroll"> ︿</div> | ||
``` | ||
## 示例4 | ||
|
||
### 百度站内搜索 | ||
```html | ||
<mip-form class="search" method="get" url="页面url"> | ||
<input class="text" type="text" name="s" data-sid="百度站内搜索密匙" id="bdcsMain" placeholder=" 请输入关键词" value=""> | ||
<input class="butto" value="" target="_blank"type="submit"> | ||
</mip-form> | ||
``` | ||
## 示例4 | ||
|
||
### 悬浮24小时热文 | ||
```html | ||
<div class="sitebar_list">悬浮内容</div> | ||
``` | ||
## 属性 | ||
|
||
### ecms-type | ||
|
||
说明:选择使用方法 | ||
必选项:是 | ||
取值范围:5 | ||
默认值:5 | ||
|
||
### ecms-classid | ||
|
||
说明:栏目ID | ||
必选项:是 | ||
ecms-type:5 | ||
|
||
### ecms-id | ||
|
||
说明:文章ID | ||
必选项:是 | ||
类型:整数 | ||
ecms-type:5 | ||
|
||
### 回滚顶部 | ||
说明:class="scroll"和id="scroll" | ||
必选项:是 | ||
|
||
### 评论验证码 | ||
说明:id="KeyImg"根据id KeyImg进行动态刷新 | ||
必选项:是 | ||
|
||
### 百度站内搜索 | ||
说明:input中的id="bdcsMain" | ||
必选项:是 | ||
|
||
说明: sid="密匙" 百度站内搜索密匙 | ||
必选项:是 | ||
|
||
### 悬浮24小时热文 | ||
说明:需要悬浮的div添加class="sitebar_list" | ||
必选项:是 |
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,99 @@ | ||
/** | ||
* 帝国cms整合 | ||
* @author: supai | ||
* @date: 2016-11-16 | ||
* @file: mip-ecms.js | ||
*/ | ||
define(function (require) { | ||
var $ = require('zepto'); | ||
var customElement = require('customElement').create(); | ||
|
||
var effects = { | ||
// 绑定事件 | ||
bindEvents: function () { | ||
// 文章点赞 | ||
$('.favorite').on('click', function (event) { | ||
event.preventDefault(); | ||
this.zan(); | ||
}); | ||
// 评论验证码刷新 | ||
$('#KeyImg').on('click', function (event) { | ||
$('#KeyImg').attr('src', '/e/ShowKey/?v=pl&' + Math.random()); | ||
}); | ||
}, | ||
// 文章点赞 | ||
zan: function () { | ||
if ($(this).hasClass('done')) { | ||
return false; | ||
} | ||
$(this).addClass('done'); | ||
var id = $(this).data('id'); | ||
var classid = $(this).data('classid'); | ||
var rateHolder = $(this).children('.count'); | ||
var ajaxData = { | ||
classid: classid, | ||
id: id, | ||
dotop: 1, | ||
doajax: 1, | ||
ajaxarea: 'diggnum' | ||
}; | ||
$.get('/e/public/digg/index.php', ajaxData, | ||
function (data) { | ||
var dingnumr = data.substring(0, data.indexOf('|')); | ||
if (!dingnumr) { | ||
$(rateHolder).html(dingnumr); | ||
} | ||
else { | ||
alert('你已经提交过了'); | ||
} | ||
|
||
}); | ||
return false; | ||
}, | ||
// 回滚页面顶部 | ||
gotoTop: function () { | ||
$(window).scroll(function () { | ||
var scrollValue = $(window).scrollTop(); | ||
scrollValue > 500 ? $('div[class=scroll]').fadeIn() : $('div[class=scroll]').fadeOut(); | ||
}); | ||
$('#scroll').click(function () { | ||
$('html,body').animate({ | ||
scrollTop: 0 | ||
}, 200); | ||
}); | ||
}, | ||
// 百度站内搜索 | ||
bdZnsv: function () { | ||
var sid = $('#bdcsMain').data('sid'); | ||
var bdcs = document.createElement('script'); | ||
bdcs.type = 'text/javascript'; | ||
bdcs.async = true; | ||
bdcs.src = 'http://znsv.baidu.com/customer_search/api/js?sid=' + sid | ||
+ '&plate_url=' + encodeURIComponent(window.location.href) | ||
+ '&t=' + Math.ceil(new Date() / 3600000); | ||
var s = document.getElementsByTagName('script')[0]; | ||
s.parentNode.insertBefore(bdcs, s); | ||
}, | ||
rightNews: function () { | ||
var elm = $('.sitebar_list'); | ||
var startPos = $(elm).offset().top; | ||
$.event.add(window, 'scroll', function () { | ||
var p = $(window).scrollTop(); | ||
$(elm).css('position', ((p) > startPos) ? 'fixed' : 'static'); | ||
$(elm).css('top', ((p) > startPos) ? '20px' : ''); | ||
}); | ||
}, | ||
// 加载绑定 | ||
init: function () { | ||
this.bindEvents(); | ||
this.gotoTop(); | ||
this.bdZnsv(); | ||
this.rightNews(); | ||
} | ||
}; | ||
|
||
customElement.prototype.build = function () { | ||
effects.init(); | ||
}; | ||
return customElement; | ||
}); |
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,9 @@ | ||
{ | ||
"name": "mip-emcs", | ||
"version": "1.4.2", | ||
"author": { | ||
"name": "supai", | ||
"email": "[email protected]" | ||
}, | ||
"description": "帝国cms,mip整合包", | ||
} |