2 Star 31 Fork 8

momo/sliderTime

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

SliderTime

介绍

时间范围滑块选择插件

基于 layui.slider 扩展的时间范围选择插件

软件架构

layui js

Demo演示

SliderTime Demo演示

安装教程

layui.config({
    base: ...
}).extend({
    sliderTime: "sliderTime/sliderTime"
});

使用说明

  1. sliderTime 基于 layui.slider,所以 slider 的配置都得以保留
  2. range 参数强制为 true
  3. 新增 disabledValue 属性,禁止选择时间范围
    例如:[["10:00", "10:30"], ["14:00", "15:30"]]
  4. 新增 disabledText 属性,禁止选择时间范围被选中后的提示内容,不配置不显示提示
    例如:"{start} - {end} 已占用",支持start和end时间占位符
  5. 新增 getValue 方法,返回当前选择的时间段(时间格式)
  6. 新增 isOccupation 方法,返回当前选择的时间段是否包含了禁止选择的时间段
  7. 新增 numToTime 公用方法,用于将十进制转为时间格式。例如:480 → 08:00
  8. 新增 timeToNum 公用方法,用于将时间格式转为十进制。例如:24:00 → 1440

示例

输入图片说明

示例代码

layui.use(['sliderTime'], function () {
    var sliderTime = layui.sliderTime;

    var slider = sliderTime.render({
          elem: '#id'  //绑定元素
        , min: "08:00"
        , max: "18:00"
        , step: 10
        , disabledValue: [["10:00", "10:30"], ["14:00", "15:30"]] // 回显禁止选择时间段
        , disabledText: '{start} ~ {end} 已占用'
        , setTips: function (value) {
            //自定义提示文本
            return sliderTime.numToTime(value);
        }, change: function (value) {
            console.log(value[0] + "-" + value[1])
        }
    });
});
MIT License Copyright (c) 2021 momo Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

时间范围滑块选择插件 基于 layui.slider 扩展的时间范围选择插件 展开 收起
JavaScript 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/momo5013/slider-time.git
git@gitee.com:momo5013/slider-time.git
momo5013
slider-time
sliderTime
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891