Giter Club home page Giter Club logo

datepicker's Introduction

DatePicker

Without jQuery-based date component with support for date ranges, muitiple calendars and more.

Params

  • el:
    • type: Element
    • required: true
    • description: Calendar container
  • trigger:
    • type: Element
    • required: true
    • description: Provoke DatePicker show and hide
    • eg: input element(onfocus show the DatePicker)
  • default:
    • type: String
    • default: 'today'
    • eg: '2017-04-15'
    • description: Default selected date
  • isRadio:
    • type: Boolean
    • default: false
    • description: Is it date radio selected?
  • lang:
    • type: String
    • options: 'EN' | 'CN'
    • default: 'EN'
    • description: The font language, for CN will use Chinese, for EN will use English
  • position:
    • type: String
    • options: 'top' | 'right' | 'left' | 'bottom'
    • default: 'bottom'
  • interval:
    • type: Array
    • default: [1970, 2030]
    • eg:[2000, 2020]
    • description: Select abled range
  • showFn:
    • type: Function
    • description: After show callback
  • hideFn:
    • type: Function
    • description: After hide callback
  • onchange:
    • type: Function
    • description: callback which observe datePicker change

Methods

  • show:
    • type: Function
  • hide:
    • type: Function

Usage

  1. manually import calendar.css and calendar.js

  2. create DatePicker contructor, for below:

    <input type="text" id="datePicker">
    <span id="calendar"></span>
    var dateComponent = new DatePicker({
           el: document.querySelector('#calendar'),
           onchange: function (curr) {
               dateInput.value = curr;
           }
    });
    
    var dateInput = document.querySelector('#datePicker');
    
    dateInput.onfocus = function () {
        dateComponent.show();
    };

datepicker's People

Contributors

frehaiku avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

datepicker's Issues

V0.3 Problems encountered.

When datePicker is opening, I click somewhere(without date itself).I want to hide.

But date field is dynamically change(used to createElement API).So If used parentNode API, you can't get document. At an early time, I think the date field how to bubble with document. Use delegates event feature?Use parentNode without null find uppermost layer element?

I read other code and find use parentNode is most common methods.For instance, freqdec/datePicker.

v0.3 todos

  • Review other codes and modify structure
  • Add some functions

v0.2 bug

Thanks to @biaodigit, the bug be found.
The reproduce step:

  1. at 2018-12-xx, click 2019-01-02;
  2. the input become 2019-13-02 and date's range is wrong.

parameter naming for selectInterval in the documentation

Hi @frehaiku

First of all, thanks for the great library, it helps me alot in my project.

Here i just want to point out in the documentation (main page the repository), there is parameter named selectInterval to put the range of the years. But I can't use it in the instantiation. After I check the code, calendar.js at line 28, it uses config.interval or default value [1970, 2030]. Therefore if I use interval instead of selectInterval it works.

So I think there is some typo in the documentation. The one stated in documentation (selectInterval) is internal variable name, not the one used in the parameter (config).

Thanks

v0.3

  • Let DatePicker disappear when click without DatePicker or trigger element (eg: input)

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.