Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ionic-datepicker-extention An extension of the ionic-datepicker made by Ignacio Chiazzo.

License

NotificationsYou must be signed in to change notification settings

ignacio-chiazzo/ionic-datepicker-extended

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is an extension of the plugin made byrajeshwarpatlolla calledionic-datepicker. As the main difference between this extension and the source one is that now the day changes if the user changes either themonth or theyear (see (gif)[http://i.makeagif.com/media/11-04-2016/M72mip.gif]).

ionic-datepicker-extension

##Prerequisites.

  • node.js, npm
  • ionic
  • bower
  • gulp

##How to use:

  1. In your project folder, please install this plugin using bower

bower install ionic-datepicker-extended --save

This will install the latest version of this plugin. If you wish to install any specific version(eg : 0.9.0) then

bower install ionic-datepicker-extended#1.2.2 --save

  1. Specify the path ofionic-datepicker.bundle.min.js in yourindex.html file.
<!-- path to ionic --><scriptsrc="lib/ionic-datepicker/dist/ionic-datepicker-extended.bundle.min.js"></script>
  1. In your application's main module, inject the dependencyionic-datepicker, in order to work with this plugin
angular.module('mainModuleName',['ionic','ionic-datepicker']){//}
  1. You can configure this date picker at application level in the config method using theionicDatePicker provider.Your config method may look like this if you wish to setup the configuration. But this is not mandatory step.
.config(function(ionicDatePickerProvider){vardatePickerObj={inputDate:newDate(),titleLabel:'Select a Date',setLabel:'Set',todayLabel:'Today',closeLabel:'Close',mondayFirst:false,weeksList:["S","M","T","W","T","F","S"],monthsList:["Jan","Feb","March","April","May","June","July","Aug","Sept","Oct","Nov","Dec"],templateType:'popup',from:newDate(2012,8,1),to:newDate(2018,8,1),showTodayButton:true,dateFormat:'dd MMMM yyyy',closeOnSelect:false,disableWeekdays:[]};ionicDatePickerProvider.configDatePicker(datePickerObj);})

In the above code i am not configuring all the properties, but you can configure as many properties as you can.

The properties you can configure are as follows.

a) inputDate(Optional) : This is the date object we can pass to the component. You can give any date object to this property. Default value isnew Date().

b) titleLabel(Optional) : Optional title for the popup or modal. If omitted or set tonull, title will default to currently selected day in formatMMM dd, yyyy

c) setLabel(Optional) : The label forSet button. Default value isSet

d) todayLabel(Optional) : The label forToday button. Default value isToday

e) closeLabel(Optional) : The label forClose button. Default value isClose

f) mondayFirst(Optional) : Settrue if you wish to show monday as the first day. Default value isfalse, which will show Sunday as the first day of the week.

g) weeksList(Optional) : This is an array with a list of all week days. You can use this if you want to show months in some other language or format or if you wish to use the modal instead of the popup for this component, you can define theweekDaysList array in your controller as shown below.

["Sun","Mon","Tue","Wed","thu","Fri","Sat"];

The default values are

["S","M","T","W","T","F","S"];

h) monthsList(Optional) : This is an array with a list of all months. You can use this if you want to show months in some other language or format. You can create an array like below.

["Jan","Feb","March","April","May","June","July","Aug","Sept","Oct","Nov","Dec"];

The default values are

["January","February","March","April","May","June","July","August","September","October","November","December"];

i) disabledDates(Optional) : If you have a list of dates to disable, you can create an array like below. Default value is an empty array.

vardisabledDates=[newDate(1437719836326),newDate(),newDate(2016,7,10),//Months are 0-based, this is August, 10th.newDate('Wednesday, August 12, 2015'),//Works with any valid Date formats like long formatnewDate("08-14-2016"),//Short formatnewDate(1439676000000)//UNIX format];

j) templateType(Optional) : This is string type which takes two values i.e.modal orpopup. Default value ismodal. If you wish to open in a popup, you can specify the value aspopup or else you can ignore it.

k) from(Optional) : This is a date object, from which you wish to enable the dates. You can use this property to disableprevious dates by specifyingfrom: new Date(). By default all the dates are enabled. Please note that months are 0 based.

l) to(Optional) : This is a date object, to which you wish to enable the dates. You can use this property to disablefuture dates by specifyingto: new Date(). By default all the dates are enabled. Please note that months are 0 based.

m) dateFormat(Optional) : This is date format used in template. Defaults todd-MM-yyyy. For how to format date, see:http://www.ecma-international.org/ecma-262/5.1/#sec-15.9.1.15

n) showTodayButton(Optional) : Boolean to specify whether to show theToday button or not. The default values isfalse.

o) closeOnSelect(Optional) : Boolean to indicate whether date picker popup/modal will be closed after selection. If set totrue,Set button will be hidden. The default value isfalse.

p) disableWeekdays(Optional) : Accepts array of numbers starting from 0(Sunday) to 6(Saturday). If you specify any values for this array, then it will disable that week day in the whole calendar. For example if you pass [0,6], then all the Sundays and Saturdays will be disabled.

  1. InjectionicDatePicker in the controller, where you wish to use this component. Then using the below method you can call the datepicker.
.controller('HomeCtrl',function($scope,ionicDatePicker){varipObj1={callback:function(val){//Mandatoryconsole.log('Return value from the datepicker popup is : '+val,newDate(val));},disabledDates:[//OptionalnewDate(2016,2,16),newDate(2015,3,16),newDate(2015,4,16),newDate(2015,5,16),newDate('Wednesday, August 12, 2015'),newDate("08-16-2016"),newDate(1439676000000)],from:newDate(2012,1,1),//Optionalto:newDate(2016,10,30),//OptionalinputDate:newDate(),//OptionalmondayFirst:true,//OptionaldisableWeekdays:[0],//OptionalcloseOnSelect:false,//OptionaltemplateType:'popup'//Optional};$scope.openDatePicker=function(){ionicDatePicker.openDatePicker(ipObj1);};};

Apart from the config method, you can re configure all options in the controller also. If you again set any of the properties, they will be overridden by the values mentioned in the controller. This will be useful if there are multiple date pickers in the app, which has different properties.

In all the above steps the only mandatory thing is thecallback where you will get the selected date value.

##Screen Shots:

Once you are successfully done with the above steps, you should be able to use this plugin.

The first screen shot shows the popup and the second shows the modal of this plugin.

iOS :

Android :

##CSS Classes:

###popup

1) prev_btn_section

2) next_btn_section

3) select_section

4) month_select

5) year_select

6) calendar_grid

7) weeks_row

8) selected_date

9) date_col

10) today

###modal

1) left_arrow

2) right_arrow

Other classes are same as the popup classes. You can use any one of the below classes to customise popup and modal css respectively.
####ionic_datepicker_popup####ionic_datepicker_modal

The css class names for the buttons are as follows

a) ForSet button the class name isbutton_set

b) ForToday button the class name isbutton_today

c) ForClose button the class name isbutton_close

##Versions:

1) v0.1.0

The whole date picker functionality has been implemented, and can be installed withbower install ionic-datepicker --save

2) v0.1.1

Bug Fix. This is the latest version ofionic-datepicker component.

3) v0.1.2

Bug Fix. If we don't pass the date to the time picker it will pick the todays date by default.

4) v0.1.3

Bug Fix

5) v0.2.0

Disabling previous dates functionality added.

6) v0.3.0

a) User can select the years and months using the dropdown.

b) A callback function is added.

7) v0.4.0

Features

a) Disabling future dates functionality added. You may use it for selecting DOB.

b) Customised title text for datepicker modal's added.

BugFixes

Bug#22,Bug#26,Bug#29

8) v0.5.0

a) Feature for disabling particular dates has been added.

b) CSS classes added for customisation.

9) v0.6.0

a) Date selection color issue fixed.

b) Added feature to show Monday as the first day of the week.

10) v0.7.0

Features

a)from andto dates functionality added.

b) Code re-structuring.

c) Updated node modules.

BugFixes

Bug#58,Bug#56,Bug#54,Bug#42,Bug#37,Bug#28

11) v0.8.0

Feature

You can use either a popup or a modal for thisionic-datepicker.

BugFix

Bug#59

12) v0.9.0

Feature

You can give your custom week names.

BugFix

Bug#63

13) v1.0.0

Features

a) You can configure the ionic-datepicker from the config method.

b) You can invoke the ionic-datepicker from the controller.

c) New CSS

d) Disabling a particular day of the calendar.

About

ionic-datepicker-extention An extension of the ionic-datepicker made by Ignacio Chiazzo.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript52.8%
  • HTML26.7%
  • CSS20.5%

[8]ページ先頭

©2009-2025 Movatter.jp