Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customizable javascript event to bind #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ Attributes
- date-format: optional, date format e.g. 'yyyy-MM-dd'
- year: optional, year selected, e.g. 2015
- month: optional, month selected, e.g. 5
- day: optiona, day selected, e.g. 31
- day: optional, day selected, e.g. 31
- hour: optional, hour selected, 23
- minute: optional, minute selected, 59
- date-only: optional, if set, timepicker will be hidden
- future-only: optional, if set, forces validation errors on dates earlier than now
- bind-event: optional, if set, the picket will show when that javascript event occurs, default is 'click' event.

Examples
--------
Expand All @@ -45,11 +46,10 @@ Examples

<input ng-model="date1" datetime-picker date-only future-only />

<input ng-model="date2" datetime-picker date-format="yyyy-MM-dd" date-only />
<input ng-model="date2" bind-event="focus" datetime-picker date-format="yyyy-MM-dd" date-only />

<input ng-model="date3" datetime-picker date-format="yyyy-MM-dd HH:mm:ss" />

<input ng-model="date4" datetime-picker hour="23" minute='59'/>

<input ng-model="date5" datetime-picker date-format="yyyy-MM-dd HH:mm:ss" year="2014" month="12" day="31" />

8 changes: 6 additions & 2 deletions angularjs-datetime-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@
hour: '=',
minute: '=',
dateOnly: '=',
closeOnSelect: '='
closeOnSelect: '=',
bindEvent: '='
},
link: linkFunc
};
Expand All @@ -322,7 +323,10 @@
}
});

element[0].addEventListener('click', function() {
// Checking the bindEvent attr, click event is the default
var bEvent = (attrs.bindEvent && attrs.bindEvent != undefined) ? attrs.bindEvent : 'click';

element[0].addEventListener(bEvent, function() {
DatetimePicker.open({
triggerEl: element[0],
dateFormat: attrs.dateFormat,
Expand Down
8 changes: 4 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ <h1>Datetime Picker</h1>
&lt;input ng-model="date4" datetime-picker date-only /> <br/>
<input ng-model="date1" datetime-picker date-only size="30" /> <br/> <br/>

&lt;input ng-model="date2" datetime-picker date-format="yyyy-MM-dd" date-only /> <br/>
<input ng-model="date2" datetime-picker date-format="yyyy-MM-dd" size="30" date-only /> <br/> <br/> <br/>
&lt;input ng-model="date2" datetime-picker bind-event="focus" date-format="yyyy-MM-dd" date-only /> <br/>
<input ng-model="date2" datetime-picker bind-event="focus" date-format="yyyy-MM-dd" size="30" date-only /> <br/> <br/> <br/>

&lt;input ng-model="date3" datetime-picker date-format="yyyy-MM-dd HH:mm:ss" close-on-select="false" /> <br/>
<input ng-model="date3" datetime-picker date-format="yyyy-MM-dd HH:mm:ss" close-on-select="false" size="30" /> <br/> <br/>
&lt;input ng-model="date3" datetime-picker bind-event="dblclick" date-format="yyyy-MM-dd HH:mm:ss" close-on-select="false" /> <br/>
<input ng-model="date3" datetime-picker bind-event="dblclick" date-format="yyyy-MM-dd HH:mm:ss" close-on-select="false" size="30" /> <br/> <br/>

&lt;input ng-model="date4" datetime-picker hour="23" minute='59'/><br/>
<input ng-model="date4" datetime-picker hour="23" minute='59' size="30" /> <br/> <br/>
Expand Down