jonthornton / jquery-timepicker

A javascript timepicker plugin for jQuery inspired by Google Calendar.
https://www.jonthornton.com/jquery-timepicker
MIT License
1.87k stars 645 forks source link

Timepicker Plugin for jQuery

timepicker screenshot

See a demo and examples here

jquery.timepicker is a lightweight timepicker plugin for jQuery inspired by Google Calendar. It supports both mouse and keyboard navigation, and weighs in at 5.5kb minified and gzipped.

Requirements

Usage

$('.some-time-inputs').timepicker(options);

Include jquery.timepicker.css and jquery.timepicker.min.js in your page.

options is an optional javascript object with parameters explained below.

You can also set options as data attributes on the intput elements, like <input type="text" data-time-format="H:i:s" />. Timepicker still needs to be initialized by calling $('#someElement').timepicker(options);. Data attributes will override any conflicting initialization options.

The defaults for all options are exposed through the $.fn.timepicker.defaults object. Properties changed in this object (same properties configurable through the constructor) will take effect for every instance created after the change.

Options

Methods

Events

The selectTime and hideTimepicker events fire slightly differently when using the useSelect option. See https://github.com/jonthornton/jquery-timepicker/issues/427 for more information.

Theming

Sample markup with class names:

<input value="5:00pm" class="ui-timepicker-input" type="text">
...
<div class="ui-timepicker-wrapper ui-timepicker-positioned-top optional-custom-classname" tabindex="-1">
    <ul class="ui-timepicker-list">
        <li class="ui-timepicker-am">12:00am</li>
        <li class="ui-timepicker-am">12:30am</li>
        ...
        <li class="ui-timepicker-pm">4:30pm</li>
        <li class="ui-timepicker-pm ui-timepicker-selected">5:00pm</li>
        <li class="ui-timepicker-pm ui-timepicker-disabled">5:30pm</li>
        <li class="ui-timepicker-pm">6:00pm <span class="ui-timepicker-duration">(1 hour)</span></li>
        <li class="ui-timepicker-pm">6:30pm</li>
        ...
        <li class="ui-timepicker-pm">11:30pm</li>
    </ul>
</div>

The ui-timepicker-positioned-top class will be applied only when the dropdown is positioned above the input.

Packaging

NPM npm install --save timepicker

CDN https://cdn.jsdelivr.net/npm/timepicker/ jsDelivr Hits

An AngularJS directive is available at https://github.com/Recras/angular-jquery-timepicker

Help

Submit a GitHub Issues request. Please try provide code that demonstrates the problem; you can use this jsFiddle as a starting point.

Development guidelines

After cloning, install dev dependencies with npm install.

jquery-timepicker follows semantic versioning.


This software is made available under the open source MIT License. © 2020 Jon Thornton and contributors