Giter Club home page Giter Club logo

angular-datepicker's Introduction

AngularJS datepicker directives

Requirements

  • Angular v1.2+
  • MomentJS
  • Moment Timezone (If timezones are being used)

Installation

via bower

bower install  angular-datepicker --save

via npm

npm install  angular-datepicker --save

After the install add the js, css and the moment files to your page.

Add the following module to your page : datePicker

Usage Example

Live demo

New features

This fork of angular-datepicker contains several features.

Timezone Support

  • The directive will work with or without a specified timezone.
  • If the timezone is known, it can be assigned to the datepicker via the timezone attribute.
  • If no timezone is provided, then the local time will be used.
No timezone information
<div date-picker></div>
Specific timezone (London, UK)
<div date-picker timezone="Europe/London"></div>
Specific timezone (Hong Kong, CN)
<div date-picker timezone="Asia/Hong_Kong"></div>

Maximum / minimum dates:

  • These attributes restrict the dates that can be selected.
  • These work differently from the original min-date and max-date attributes, which they replace.
  • The original attributes allow selecting any dates and just mark the input as invalid.
  • With these attributes, if a date in the picker is outside of the valid range, then it will not be selectable.
Minimum date:
<input date-time min-date="minDate">
Maximum date:
<input date-time max-date="maxDate">
Minimum and maximum date:
<input date-time min-date="minDate" max-date="maxDate">

Date format (for input fields):

  • A custom format for a date can be assigned via the format atribute.
    • This format will be used to display the date on an input field.
    • If not provided, a default format will be used.
    • See: format options
<input date-time format="yyyy-MM-dd HH:mm">

Callback on date change

  • Adding a date-change attribute containing a function name will cause this function to be called when the date changes in the picker.
<input date-time date-change="changeDate">

Update events

  • An event can be broadcast from the parent scope which will update specific pickers with new settings. The settings which can be changed are:
    • minDate: Earliest selectable date for this picker. Disabled if this value is falsy.
    • maxDate: Latest selectable date for this picker. Disabled if this value is falsy.
    • minView: Minimum zoom level for date/time selection. Disabled if this value is falsy.
    • maxView: Maximum zoom level for date/time selection. Disabled if this value is falsy.
    • view: Default zoom level for date/time selection. Set to default value if this value is falsy.
    • format: Format string used to display dates on the input field. Set to default value if this value is falsy.
      • See: format options
      • This option cannot be used on the date-picker directive directly, it must be used on a date-time input field.
  • The possible for the view, minView and maxView fields are:
    • year, month, date, hours, minutes.
  • The event is targeted at specific pickers using their ID attributes.
    • If a picker exists with the same ID then the information in this picker will be updated.
    • A single ID can be used, or an array of IDs

Create picker with ID

<input date-time id="pickerToUpdate">

Update one picker.

$scope.$broadcast('pickerUpdate', 'pickerToUpdate', {
	format: 'D MMM YYYY HH:mm',
	maxDate: maxSelectableDate, //A moment object, date object, or date/time string parsable by momentjs
	minView: 'hours',
	view: false //Use default
});

Update multiple pickers.

$scope.$broadcast('pickerUpdate', ['pickerToUpdate', 'secondPickerToUpdate'], {
	format: 'lll'
});

angular-datepicker's People

Contributors

aaronroberson avatar anton-bocharov-3shape avatar apexskier avatar arned avatar astik avatar bulutcy avatar chrisconley avatar cloutierlp avatar dantalash avatar eralha avatar fbatiga avatar g00fy- avatar hi-fi avatar janantala avatar jharting avatar kuzzmi avatar lcarnevaleow avatar lperrin avatar qivan avatar saliba avatar santiagovazquez avatar schizoduckie avatar set321go avatar shawnstrickland avatar silverwolfx10 avatar stefan-sopic avatar tehasdf avatar tfoxy avatar twjacobsen avatar westberliner 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  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  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

angular-datepicker's Issues

Please document License

Hi,
We'd like to use this widget in one of my project and we need to know the license for the library. Could you please document the license?

thanks
-jason

Datepicker appears only after focus is newly set to button element in popup mode (dismiss config set to true)

I'm new to AngularJS and I'm trying to use datepicker as popup picker setting dismiss config to true. But once clicked and got focus (so that showPicker function is called and picker successfully appeared) the button keeps its focus after the date is picked and picker disappeared. So next clicks on the same button don't call showPicker and picker doesn't appear until the focus is manually moved to some other element. Can this be fixed, please?

Global namespace pollution

It may just be me misunderstanding something but it seems that there is a lot of global namespace pollution in datepicker.js. There are a whole bunch of functions which are declared globally (isAfter, isBefore, isSameYear, etc.).

I have a problem where I have a pop-up form containing a datepicker. In the page beneath the form I also have a datepicker. If I use the datepicker in the pop-up form and then close (i.e. destroy) the form, I then get a whole bunch of missing function errors when I do any dom manipulation on the page beneath.

I don't really know why this is happening but I suspect it is to do with these global functions, which are the ones being called. E.g.

TypeError: undefined is not a function
at isSameYear (/angular-datepicker-master/app/scripts/datePicker.js:128:25)
at isSameMonth (/angular-datepicker-master/app/scripts/datePicker.js:132:10)
at isSameDay (/app/scripts/datePicker.js:136:10)
at isSameHour (/angular-datepicker-master/app/scripts/datePicker.js:140:10)
at Scope.scope.isSameHour (/angular-datepicker-master/app/scripts/datePicker.js:299:32)

JSLint issues

Please run your distributions through JSLint... So many duplicate "use strict" and var Module are present...

Also the bitwise operators give JSLint errors, so either refactor or add

/*jslint bitwise: true */

Blank date required

I am looking to see if this control can be used when a date can be entered or not depending on needs. In my case the user records the last date an event occurred, but it is possible that the event has not occurred before and should be blank. Currently the angularJS Model is not updated by clearing an input box:

<input required="false"  format="yyyy-MM-dd" type="text" min-view="date" date-time data-ng-model="last_action">{{last_action}}

Is there a way to allow the clearing of the input box to update the model?

Time zone offset

Although I'm selecting 9am in the morning and that's the value showing in my field. The actual value that get's input to the angularJS model is 2 hours earlier.

Why would that be and how can I correct for this offset?

Create a new version from the master branch

Hey, first of all, amazing datepicker.

We are using bower in our project and we wanted to know if it is possible for you to create a new version with the current master branch that fixes the minifying problem of PR #24 ?

Thanks!

change date format

The output from this seems to be ISO (i.e. YYYY-MM-DD"T"HH:MM:SS"0Z")
Is there any way to alter the output format?

Odd thing is that it shows the correct format in the field, but when the data from the model that the field updates is submitted via $http the date's format is ISO.

date range multiple active dates

i use the directive like this:
<div date-range start="model.filters.startTime" end="model.filters.endTime"></div>
by random clicking and double clicking i easily end up with something like this image shows
datepicker bug

Improve css

  1. set default width for datepicker element
  2. change datepicker position to relative
  3. set width of tds to percent values

min/max limit

in the current implementation you can limit the dates by using:

    $scope.$watch 'model.filters.endTime', (value) ->
        if value > new Date()
            $scope.model.filters.endTime = new Date()

but this still allows the user to navigate to unwanted future days

i think there should be a min/max limit that blocks the user from navigating outside the wanted range, i recommand using the min and max attribute and integrate them like they work for the input[date] element

Input and Android soft keyboard issue

On an Android tablet using this component causes the soft keyboard to appear when you focus into the control and are trying to select dates which (on my form) is obscuring the control.

lack of documentation/demonstration

Hi,

I would like to try your datepicker, but it doesn't work out of the box for me.
My I don't use it right. A little more dokumetation or a demo on fiddler or plunker may help.

You've did a bower package and the module ist on ngmodules so I guess it is ready for use.

Which browsers do you support?

Calendar mode with EventSource Service

I made some patches here and there to create a proper angularjs calendar directive that supports showing events on a calendar like the crappyheavily bloated, jquery and jquery-ui-based angular-ui calendar.

Since event templates are most likely something you want to customize I made this an external template, this also allows for binding ng-click events from outside the directive without going through too many hoops.

I've included a standard event service and defined a minimal api to start with.

It could still use some polishing probably, but please take a look and see if you want to merge it. I'll send a pull request from my branch.
a603bf1e-9742-11e3-9c78-486d55cd8dff 1

Using date-time on input: on first click on a date it scrolls to top of page.

If you have something like:
<input type="text" date-time partial="true" ng-model="date" view="date" max-view="date" min-view="date"/>
On the first click on a date it scrolls to top of page.

But I found a fix and an explanation on why it works on the demo page.
If you add this to the page it somehow doesn't do it:
<div date-picker style="display: none"></div>

date-range granularity

Hey, I'd like to be able to set times on a date-range. Wondering if this is possible or anywhere on the roadmap?

Doesn't work on Galaxy Nexus S Android 4.1.1

It pops up but the phone acts like it's only an edit control and no amount of touches will activate the popup calendar component for selection.

And with this issue I'm forced to move on, this is too bad because I really like the simplicity and ease of use of this control but it's clearly not ready for mobile at all.

How to modify template path in config?

I'm probably just missing something but... when I tried to implement this in my project the template path being relative wasn't working so.. how do I modify the config?

localization

is there plans to add multilanguage support for months and days of the week names?

Duplicate Date

Because of Daylight saving, the day that changed the time it is duplicated.

example:

10/18/2014 00:00:00 + One Day
10/18/2014 23:00:00

Is it still active ?

Hi,

Is this repo still active ?
Your datepicker seems really interesting but

  • bower install is completly broken (no main files declared in bower version, wrong version numbers 1.0.0 instead of 1.0.3...)
  • many pull resquests not merged and issue not responded
  • demo is a little broken
  • documentation is really poor ...

I would love to help on some parts but I want to be sure that this repos is still active and my work will be usefull.

Thanks !

Add production dependencies to bower.json

Hi,

Our team is currently testing several datetime pickers to find out which one could best fit our needs.

We were surprised to see that only development dependencies are currently defined for bower and npm.

bower.json
package.json

According to the README, I know about Angular 1.2+ but not sure if this module requires something else.

So I would suggest this move in bower.json

"dependencies": {
  "angular": "~1.2.0"
}

Thanks.

not clear how to include this in your own angular project

The instructions say how to 'build' it, but it's more useful to have instructions on how to include it in your own project.

I took the following steps:

bower install angular-datepicker

added to index.html (as copied from the example):

<script src="bower_components/angular-datepicker/app/scripts/datePicker.js"></script>
<script src="bower_components/angular-datepicker/app/scripts/dateRange.js"></script>
<script src="bower_components/angular-datepicker/app/scripts/input.js"></script>

(it seems one script tag should be enough, why make users include 3?)

Add 'datePicker' to the dependencies of your angular.module

This ends up complaining about not finding the template, so as I'm unsure how the templates are supposed to be found by the script files, I symlinked them into my app dir:

ln -sf pwd/app/bower_components/angular-datepicker/app/templates/datepicker.html app/templates/

Now I'm at the point where I get an unstyled widget, I'm sure the .css needs adding somewhere too, but I'm a bit tired at this point to do trial and error to get this to work.

Timezone

Any plans to include timezone selection? I have a requirement in a project to include timezone selection for an enterprise application.

discussion: feature request for new version

I want to rewrite the whole thing as there has been some bad design decisions made in the past. What I am planning to do:

  1. Still have separate date-picker date-range input[type=date] directives
  2. Handle positioning differently (position absolute & observe window as using current implementation breaks on some pages.
  3. Change syntax of attributes/settings from max-view to something similar to ng-model-options="options"
  4. Remove the template option as this creates some overhead and makes dealing with ngModelController harder. If you still want to use custom templates then you could do:
angular.module('module',[]). directve('myCustomDatePickerDirective', function(datePickerDirective){
   return angular.extend({},datePickerDirective[0],{templateUrl:'your template'});
});
  1. Integrate with ngModelOptions (use update and debounce)
  2. Don't require jQuery
  3. Provide customizable parser that would try match format
  4. Still thinking on this - support date as string (just like <input type="datetime-local"> does)
  5. rename dist/index.js to angular-datepicker.js etc.

Please feel free to add any requests, usecases or suggestions.

Autoclose

Autoclose of the datepicker when selecting a value on the min-view would be very appreciated ๐Ÿ‘

Starting view attribute

If there is a date defined on the model, I'd like to be able to say starting-view="date" or something similar, to default to the "date" view when first clicked.

Normalize attribute (data-) break the range coloration

From the demo, goring from :

<div date-range start="a" end="b" style="position: relative; z-index:0"></div>

to :

<div data-date-range data-start="a" data-end="b" style="position: relative; z-index:0"></div>

What is weird is, it works with :

<div date-range data-start="a" data-end="b" style="position: relative; z-index:0"></div>

When you normalize the date-range attribute, the coloration ceases to work ='(

stops working when upgrading from angular 1.3.0-build.2991+sha.9025113 to 1.3.0-beta.7

I was using datepicker as follows:

<div class="dropdown-menu" ng-click="update()">
<div date-picker="due" max-view="year" min-view="date">
</div>
</div>

In both versions it works if $scope.due is set to a value.

If it is set to undefined, and the version is 1.3.0-beta.7 (the next release candidate) it stops working, and generates this exception:

TypeError: undefined is not a function
at http://0.0.0.0:9001/bower_components/angular/angular.js:22066:55
at publicLinkFn (http://0.0.0.0:9001/bower_components/angular/angular.js:6264:29)
at boundTranscludeFn (http://0.0.0.0:9001/bower_components/angular/angular.js:6406:21)
at controllersBoundTransclude (http://0.0.0.0:9001/bower_components/angular/angular.js:7047:18)
at http://0.0.0.0:9001/bower_components/angular/angular.js:22064:27
at processQueue (http://0.0.0.0:9001/bower_components/angular/angular.js:12018:27)
at http://0.0.0.0:9001/bower_components/angular/angular.js:12034:27
at Scope.$eval (http://0.0.0.0:9001/bower_components/angular/angular.js:13202:28)
at Scope.$digest (http://0.0.0.0:9001/bower_components/angular/angular.js:13014:31)
at Scope.$delegate.proto.$digest (:844:31)

style.less doesn't work with recent less compiler

Getting

ParseError: Unrecognised input in app/bower_components/angular-datepicker/app/styles/mixins.less on line 558, column 3:
557
558 .core (@gridColumnWidth, @gridGutterWidth) {
559
Warning: Error compiling app/styles/main.less Use --force to continue.

googling seems to suggest that this is due to bootstrap2 css being used and not being compatible with recent less versions.

Not working in Directive with isolated scope

Hello,

I just refactored one of my directives into more reusable component - I used isolate scope. date-time stopped working after that.

Here is a live demo. Just uncomment the scope definition in directive's code to observe the problem.

I was fiddling around and figured out that this can be solved by replacing scope.$digest() to scope.$apply() in focus binding.

'date' view shows one week too many

The current while loop doesn't take into account that the month could have ended already in the current week it's processing, showing a maximum of 7 rows for a month display.

This can be tuned down to max 6 and be variable to min. 4 in some cases.
Without PR:
image
With PR:
image

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.