Giter Site home page Giter Site logo

albertlopezquantion / mydatepicker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kylebradshaw/mydatepicker

0.0 1.0 0.0 6.06 MB

Angular2 date picker

Home Page: http://kekeh.github.io/mydatepicker

License: MIT License

JavaScript 8.54% HTML 14.36% TypeScript 59.16% CSS 17.94%

mydatepicker's Introduction

mydatepicker v. 0.0.30

Angular 2 date picker - Angular2 reusable UI component

Description

Simple Angular2 date picker. Online demo is here

Installation

To install this component to an external project, follow the procedure:

  1. npm install mydatepicker --save

  2. Add MyDatePickerModule import to your @NgModule like example below

    import { NgModule } from '@angular/core';
    import { BrowserModule } from '@angular/platform-browser';
    import { MyTestApp } from './my-test-app';
    import { MyDatePickerModule } from 'mydatepicker/src/my-date-picker/my-date-picker.module';
    
    @NgModule({
        imports:      [ BrowserModule, MyDatePickerModule ],
        declarations: [ MyTestApp ],
        bootstrap:    [ MyTestApp ]
    })
    export class MyTestAppModule {}
  3. Use the following snippet inside your template:

    <my-date-picker [options]="myDatePickerOptions"
                    (dateChanged)="onDateChanged($event)"></my-date-picker>
  • Mandatory attributes:

    • [options]="myDatePickerOptions"
    • (dateChanged)="onDateChanged($event)"
  • Optional attributes:

    • [selDate]="selectedDate" || [defaultMonth]="defaultMonth"
    • [locale]="locale"
  • Example of the options data (not all properties listed):

    myDatePickerOptions = {
        todayBtnTxt: 'Today',
        dateFormat: 'yyyy-mm-dd',
        firstDayOfWeek: 'mo',
        sunHighlight: true,
        height: '34px',
        width: '260px',
        inline: false,
        disableUntil: {year: 2016, month: 8, day: 10},
        selectionTxtFontSize: '16px'
    };
  • Example of the date changed callback:
    onDateChanged(event:any) {
        console.log('onDateChanged(): ', event.date, ' - formatted: ', event.formatted, ' - epoc timestamp: ', event.epoc);
    }

Usage

options attribute

Value of the options attribute is a javascript object. It can contain the following properties.

Option Default Description
dayLabels {su: 'Sun', mo: 'Mon', tu: 'Tue', we: 'Wed', th: 'Thu', fr: 'Fri', sa: 'Sat'} Day labels visible on the selector.
monthLabels { 1: 'Jan', 2: 'Feb', 3: 'Mar', 4: 'Apr', 5: 'May', 6: 'Jun', 7: 'Jul', 8: 'Aug', 9: 'Sep', 10: 'Oct', 11: 'Nov', 12: 'Dec' } Month labels visible on the selector.
dateFormat yyyy-mm-dd Date format on selection area and callback.
todayBtnTxt Today Today button text.
firstDayOfWeek mo First day of week on calendar. One of the following: mo, tu, we, th, fr, sa, su
sunHighlight true Sunday red colored on calendar.
disableUntil no default value Disable dates backward starting from the given date. For example: {year: 2016, month: 6, day: 26}
disableSince no default value Disable dates forward starting from the given date. For example: {year: 2016, month: 7, day: 22}
disableWeekends false Disable weekends (Saturday and Sunday).
inline false Show mydatepicker in inline mode.
height 34px mydatepicker height without selector. Can be used if inline = false.
width 100% mydatepicker width. Can be used if inline = false.
selectionTxtFontSize 18px Selection area font size. Can be used if inline = false.
alignSelectorRight false Align selector right. Can be used if inline = false.
indicateInvalidDate true If user typed date is not same format as dateFormat, show red background in the selection area. Can be used if inline = false.
showDateFormatPlaceholder false Show value of dateFormat as placeholder in the selection area if it is empty. Can be used if inline = false.

locale attribute

A two-letter ISO 639-1 language code can be provided as shorthand for several of the options listed above. Currently supported languages: en, fr, ja and fi. If the locale attribute is used it overrides dayLabels, monthLabels, dateFormat, todayBtnTxt, firstDayOfWeek and sunHighlight properties from the options.

  • new locale data can be added to this file.

selDate attribute

Provide the initially chosen date that will display both in the text input field and provide the default for the popped-up selector.

defaultMonth attribute

If selDate is not specified, when the datepicker is opened, it will ordinarily default to selecting the current date. If you would prefer a different year and month to be the default for a freshly chosen date picking operation, specify a [defaultMonth] in the same format as that for the datepicker options (yyyy.mm if not otherwise specified).

Development of this component

To develop this component, follow the procedure:

  1. Fork and clone this repo
  2. Execute npm install
  3. Open a terminal and type npm start
  4. Open http://localhost:5000 to browser

Demo

Online demo is here

Compatibility (tested with)

  • Firefox (latest)
  • Chromium (latest)
  • Edge
  • IE11

License

  • License: MIT

Author

  • Author: kekeh

mydatepicker's People

Contributors

rapropos avatar fornever avatar zefling avatar rjbazan avatar

Watchers

Albert López 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.