Coder Social home page Coder Social logo

lukanetconsult / material-time-picker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alvinthen/material-timepicker

0.0 3.0 0.0 694 KB

Material design time picker

Home Page: https://pickers.nickc.io/time.html

License: MIT License

JavaScript 88.78% HTML 2.56% CSS 8.66%

material-time-picker's Introduction

material-pickers-time

Install

npm install material-pickers-time

Build

Requires the use of the gulp task runner and babel cli. To install globally, use npm install -g gulp babel-cli

  • Build - gulp
  • Test - gulp test:js
  • Run Locally - npm start
  • Build module-ready version - gulp && npm run build

About

Currently, the Material Design Lite project doesn't have any picker features implemented. There are a few other OS material picker libraries but they are either not actively maintained, or require heavy dependencies.

In need of a timepicker for a current project I made this library. Built with vanilla JavaScript and no dependencies. Written in ES6 and SASS.

The library currently supports both 12 and 24 time formats.

To check out live examples and view the test runner check out https://pickers.nickc.io/time.html

Options

Current only one option is implemented to change between 12 and 24 hour time. They are passed when one of the public API methods are called, merged with default options, and set the property mtpOptions on the input element specified.

{
timeFormat: standard or military by default it will be standard
}

API

bindInput

Adds an event listener to input element specified. When the input element triggers a focus event the timepicker will open.

parameters

inputEl: either a string selector, or a HTMLElement
options: (optional) options object to be set to input element object

example

const timepicker = new TimePicker();

// using a selector with no options
timepicker.bindInput('#selector');

// using a cached element with 24 time format
timepicker.bindInput(cachedEl, {timeFormat: 'military'});

openOnInput

Better suited for use in a framework environment where you want more customized control over the picker. When called it will immediately open with the input element specified in context.

parameters

inputEl: either a string selector, or a HTMLElement
options: (optional) options object to be set to input element object

example

const timepicker = new TimePicker();
const standardInput = document.querySelectorAll('#standard-input');

standardInput.on('focus', event => timepicker.openOnInput(event.target));

material-time-picker's People

Contributors

hownowbrowncow avatar wesleyklop avatar tux-rampage avatar hasmichaels avatar th3fallen avatar ranneyd avatar

Watchers

James Cloos avatar Hartmut Ludwig avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.