diff --git a/examples/rate.html b/examples/rate.html index ea11359..0010e8a 100644 --- a/examples/rate.html +++ b/examples/rate.html @@ -55,28 +55,38 @@ layui.use(['rate'], function(){ var rate = layui.rate; //渲染 + // var ins1 = rate.render({ + // elem: '#test1' + // ,length: 7 + // ,value: 4 + // }); + // ins1.setValue(5); + + rate.render({ - elem: '#test1', - length: 7, - value: 4 + elem: '#test1' + ,length: 7 + ,value: 4 + }) + + rate.render({ + elem: '#test2' + ,length: 6 + ,value: 2 + ,half: true }) rate.render({ - elem: '#test2', - length: 6, - value: 2, - half: true + elem: '#test3' + ,length: 5 + ,value: 2.5 + ,text: true + ,half: true }) rate.render({ - elem: '#test3', - length: 5, - value: 3, - text: true - }) - rate.render({ - elem: '#test4', - length: 8, - value: 5, - reader: true + elem: '#test4' + ,length: 8 + ,value: 5 + ,reader: true }) }); diff --git a/src/css/layui.css b/src/css/layui.css index 339b4df..d6489d5 100644 --- a/src/css/layui.css +++ b/src/css/layui.css @@ -1037,7 +1037,7 @@ body .layui-table-tips .layui-layer-content{background: none; padding: 0; box-sh .layui-upload-wrap .layui-upload-file{display: block!important; position: absolute; left: 0; top: 0; z-index: 10; font-size: 100px; width: 100%; height: 100%; opacity: .01; filter: Alpha(opacity=1); cursor: pointer;} /** 评分组件 **/ -.layui-icon-rate,.layui-icon-rate-solid{font-size: 24px;color: #FF7F00;} +.layui-icon-rate,.layui-icon-rate-solid,.layui-icon-rate-half{font-size: 24px;color: #FFB800;} .layui-rate-div{height: 120px;border: 1px solid #EEE;border-radius: 5px;padding: 20px;margin-top: 10px;margin-bottom: 10px;transition: 300ms;} .layui-rate-div:hover{box-shadow: 0 0 10px #CCC; transition: 300ms;} .layui-rate{display: inline-block;list-style: none;padding: 20px;} diff --git a/src/lay/modules/rate.js b/src/lay/modules/rate.js index cb7564b..8e520bc 100644 --- a/src/lay/modules/rate.js +++ b/src/lay/modules/rate.js @@ -22,6 +22,22 @@ layui.define('jquery',function(exports){ } } + //操作当前实例 + ,thisRate = function(){ + var that = this + ,options = that.config; + + return { + + function(value){ + console.log(options) + + //that.setValue(); + } + ,config: options + } + } + //字符常量 ,MOD_NAME= 'rate', ICON_RATE = 'layui-icon layui-icon-rate', ICON_RATE_SOLID = 'layui-icon layui-icon-rate-solid', ICON_RATE_HALF = 'layui-icon layui-icon-rate-half' @@ -47,68 +63,94 @@ layui.define('jquery',function(exports){ Class.prototype.render = function(){ var that = this ,options = that.config; + var temp='