From 6bb530020b87a4ee7dd4eab768620a2b44a0fadb Mon Sep 17 00:00:00 2001 From: mip-platform Date: Tue, 27 Jun 2017 18:23:52 +0800 Subject: [PATCH] update extensions --- mip-fn-comment-reply/README.md | 42 +++++++++++++ mip-fn-comment-reply/mip-fn-comment-reply.js | 62 +++++++++++++++++++ .../mip-fn-comment-reply.less | 6 ++ mip-fn-comment-reply/package.json | 12 ++++ 4 files changed, 122 insertions(+) create mode 100644 mip-fn-comment-reply/README.md create mode 100644 mip-fn-comment-reply/mip-fn-comment-reply.js create mode 100644 mip-fn-comment-reply/mip-fn-comment-reply.less create mode 100644 mip-fn-comment-reply/package.json diff --git a/mip-fn-comment-reply/README.md b/mip-fn-comment-reply/README.md new file mode 100644 index 00000000..d0c82a4a --- /dev/null +++ b/mip-fn-comment-reply/README.md @@ -0,0 +1,42 @@ +# mip-fn-comment-reply +

蜂鸟网WAP站评论回复

+ +## 示例 +```html + + 可以试试用这个调片,感谢分享 + +``` + +标题|内容 +----|---- +类型|通用 +所需脚本|http://mipcache.bdstatic.com/static/v1/mip-fn-comment-reply/mip-fn-comment-reply.js + +## 属性 +### replyid +说明:回复评论所属id +必选项:是 +类型:Number + +### reply_path +说明: 回复的path +必选项:是 +类型:Number + +### reply_userid +说明:回复的userid +必选项:是 +类型:字符串 +取值范围:Number + +### reply_username +说明:回复的username +必选项:是 +类型:字符串 + + + + + + diff --git a/mip-fn-comment-reply/mip-fn-comment-reply.js b/mip-fn-comment-reply/mip-fn-comment-reply.js new file mode 100644 index 00000000..2a830c50 --- /dev/null +++ b/mip-fn-comment-reply/mip-fn-comment-reply.js @@ -0,0 +1,62 @@ +/** + * @file mip-fn-reply 组件 + * @author wangyan + */ +define(function (require) { + var zepto = require('zepto'); + var customElem = require('customElement').create(); + + // 生命周期 function list,根据组件情况选用,(一般情况选用 build、firstInviewCallback) start + // build 方法,元素插入到文档时执行,仅会执行一次 + customElem.prototype.build = function () { + // this.element 可取到当前实例对应的 dom 元素 + var element = this.element; + var replyid = element.getAttribute('replyid'); + var replyPath = element.getAttribute('reply_path'); + var replyUserid = element.getAttribute('reply_userid'); + var replyUsername = element.getAttribute('reply_username'); + + element.addEventListener('touchstart', function () { + var obj = document.getElementById('content'); + obj.setAttribute('replyid', replyid); + obj.setAttribute('reply_path', replyPath); + obj.setAttribute('reply_userid', replyUserid); + obj.setAttribute('reply_username', replyUsername); + obj.value = '回复@' + replyUsername + ':'; + }, false); + + }; + + // 创建元素回调 + customElem.prototype.createdCallback = function () { + // console.log('created'); + }; + // 向文档中插入节点回调 + customElem.prototype.attachedCallback = function () { + // console.log('attached'); + }; + // 从文档中移出节点回调 + customElem.prototype.detachedCallback = function () { + // console.log('detached'); + }; + // 第一次进入可视区回调,只会执行一次,做懒加载,利于网页速度 + customElem.prototype.firstInviewCallback = function () { + // console.log('first in viewport'); + }; + // 进入或离开可视区回调,每次状态变化都会执行 + customElem.prototype.viewportCallback = function (isInView) { + // true 进入可视区;false 离开可视区 + // console.log(isInView); + }; + // 控制viewportCallback、firstInviewCallback是否提前执行 + // 轮播图片等可使用此方法提前渲染 + customElem.prototype.prerenderAllowed = function () { + // 判断条件,可自定义。返回值为true时,viewportCallback、firstInviewCallback会在元素build后执行 + return !!this.isCarouselImg; + }; + // 生命周期 function list,根据组件情况选用 end + + + return customElem; +}); + diff --git a/mip-fn-comment-reply/mip-fn-comment-reply.less b/mip-fn-comment-reply/mip-fn-comment-reply.less new file mode 100644 index 00000000..49a7effb --- /dev/null +++ b/mip-fn-comment-reply/mip-fn-comment-reply.less @@ -0,0 +1,6 @@ +mip-fn-comment-reply{ + font-size: 0.65rem; + line-height: 1.0rem; + word-wrap: break-word; + word-break: break-all; +} \ No newline at end of file diff --git a/mip-fn-comment-reply/package.json b/mip-fn-comment-reply/package.json new file mode 100644 index 00000000..d46998c4 --- /dev/null +++ b/mip-fn-comment-reply/package.json @@ -0,0 +1,12 @@ +{ + "name": "mip-fn-comment-reply", + "version": "1.0.0", + "description": "蜂鸟网WAP站评论回复", + "author": { + "name": "fn", + "email": "tech@fengniao.com" + }, + "engines": { + "mip": ">=1.1.0" + } +} \ No newline at end of file