GithubHelp home page GithubHelp logo

babakhani / pwt.datepicker Goto Github PK

View Code? Open in Web Editor NEW
605.0 19.0 139.0 5.09 MB

Javascript jalaali calendar capable datepicker widget

Home Page: http://babakhani.github.io/PersianWebToolkit/datepicker

JavaScript 66.36% CSS 17.88% HTML 15.76%
persian-datepicker datepicker jalaali-date-picker

pwt.datepicker's Introduction

Persian Date Picker

This Date picker work with Iranian calendar.

Jalali calendar datepicker, which depends on persianDate

More info at Wikipedia

Note: from v1.0.0 persianDatepicker support gregorian calendar

npm version Bower version Travis-ci

Star Issue Fork

Table of content:

CDN

Dependency

persian-datepicker 1.x.x need persian-date 1.x.x

Install

npm install persian-datepicker

bower install persian-datepicker

Usage

<head>
  <link rel="stylesheet" href="css/persian.datepicker.css"/>
  <script src="js/jquery.js"></script>
  <script src="js/persian.date.js"></script>
  <script src="js/persian.datepicker.js"></script>
</head>

<script type="text/javascript">
  $(document).ready(function() {
    $(".example1").pDatepicker();
  });
</script>

<input type="text" class="example1" />

Options table

Options full document

name type default description
calendarType string 'persian' Set default calendar mode of datepicker, available options: 'persian', 'gregorian'
calendar object Calendar type and localization configuration
calendar.persian object Persian calendar configuration
calendar.persian.locale string 'fa' Set locale of Persian calendar available options: 'fa', 'en'
calendar.persian.showHint boolean false If set true, small date hint of this calendar will be shown on another calendar
calendar.persian.leapYearMode string algorithmic Persian calendar leap year calculation mode, available options: 'algorithmic', 'astronomical'
calendar.gregorian object Gregorian calendar configuration
calendar.gregorian.locale string 'en' set locale of Gregorian calendar available options: 'fa', 'en'
calendar.gregorian.showHint boolean false If set true, small date hint of this calendar will be shown on another calendar
responsive boolean true If set true make enable responsive view on mobile devices
initialValue boolean true If set true datepicker init with input value date, use data-date property when you want set inline datepicker initial value
initialValueType string 'gregorian' Initial value calendar type, accept: 'persian', 'gregorian'
inline boolean false If set true datepicker render inline
persianDigit (DEPRECATED from 1.0.0) boolean true If set true all digit shows as persian digit
viewMode string 'day' Accept 'day', 'month', 'year'
format string 'LLLL' The date format, combination of d, dd, m, mm, yy, yyy. format document
formatter function function(unixDate){return unixDate} Main Input value formatter function
altField string null An input element that is to be updated with the selected date from the datepicker. Use the altFormat option to change the format of the date within this field. Leave as blank for no alternate field. acceptable value: : '#elementId','.element-class'
altFormat string 'unix' The date format, combination of d, dd, m, mm, yy, yyy. format document
altFieldFormatter function function(unixDate){return unixDate} Format value of alt field input input
minDate Unix Offset null Set min date on datepicker, prevent user select date before given unix time
maxDate Unix Offset null Set max date on datepicker, prevent user select date after given unix time
navigator object Navigator config object
navigator.enabled boolean true Make navigator enable or disable
navigator.scroll object Navigate by scroll configuration
navigator.scroll.enabled boolean true If you want prevent to navigate with mouse-wheel event make this option false
navigator.text object Navigator text config object
navigator.text.btnNextText string '<' Text of next button
navigator.text.btnPrevText string '>' Text of previews button
navigator.onNext event function (navigator) {} Called when navigator goes to next state
navigator.onPrev event function (navigator) {} Called when navigator goes to prev state
navigator.onSwitch event function (state) {} Called when navigator switch
toolbox object Toolbox object options.
toolbox.enabled boolean true Enable/Disable toolbox object
toolbox.text (DEPRECATED from 1.0.0) object
toolbox.text.btnToday (DEPRECATED from 1.0.0) string 'امروز' Today button text
toolbox.todayButton object Toolbox today button configuration
toolbox.todayButton.enabled boolean false Make toolbox today button enable or disable
toolbox.todayButton.text object Today button text
toolbox.todayButton.text.fa string 'امروز' Show when current calendar is Persian
toolbox.todayButton.text.en string 'Today' Show when current calendar is Gregorian
toolbox.todayButton.onToday event function () {} Called when today button clicked
toolbox.submitButton object Toolbox today button configuration
toolbox.submitButton.enabled boolean true Make toolbox submit button enable or disable
toolbox.submitButton.text object Submit button text
toolbox.submitButton.text.fa string 'تایید' Show when current calendar is Persian
toolbox.submitButton.text.en string 'submit' Show when current calendar is Gregorian
toolbox.submitButton.onSubmit event function () {} Called when submit button clicked
toolbox.calendarSwitch object
toolbox.calendarSwitch.enabled boolean true Make calendar switch enable or disable
toolbox.calendarSwitch.format string 'MMMM' Calendar switch text format string
toolbox.calendarSwitch.onSwitch event function () {} Called when calendar switch clicked
toolbox.onToday (DEPRECATED from 0.6.0) event function(toolbox){return unixDate} Event called when today btn clicked
onlyTimePicker (mode) boolean false If true, all pickers hide and just show timepicker
onlySelectOnDate boolean true If true, date select just by click on day in month grid, and when user select month or year selected date doesnt change
checkDate function function (unix) { return true; } Validate date access before render
checkMonth function function (month) { return true; } Validate month access before render
checkYear function function (year) { return true; } Validate year access before render
timePicker object
timePicker.enabled boolean false Make timePicker enable or disable
timePicker.step int 1 The amount that increases or decreases by pressing the button
timePicker.hour object
timePicker.hour.enabled boolean true Enable/Disable hour in timepPicker object
timePicker.hour.step int null The amount that increases or decreases hour, by pressing the button. overwrite by timepicker.step
timePicker.minute object
timePicker.minute.enabled boolean true Enable/Disable minute in timePicker object
timePicker.minute.step int null The amount that increases or decreases minute, by pressing the button. overwrite by timepicker.step
timePicker.second object
timePicker.second.enabled boolean true Enable/Disable second in timePicker object
timePicker.second.step int null The amount that increases or decreases second, by pressing the button. overwrite by timepicker.step
timePicker.meridian object
timePicker.meridian.enabled boolean true Enable/Disable meridian in timePicker object
dayPicker object
dayPicker.enabled boolean true Enable/Disable dayPicker object
dayPicker.titleFormat string 'YYYY MMMM' DayPicker title format string
dayPicker.titleFormatter function function (year, month) {} DayPicker title formatter function
dayPicker.onSelect event function (selectedDayUnix) {} Called when date select by user
monthPicker object
monthPicker.enabled boolean true Enable/Disable monthPicker object
monthPicker.titleFormat string 'YYYY' MonthPicker title format string
monthPicker.titleFormatter function function (unix) {} MonthPicker title formatter function
monthPicker.onSelect event function (monthIndex) {} Called when month select by user
yearPicker object
yearPicker.enabled boolean true Enable/Disable yearPicker object
yearPicker.titleFormat string 'YYYY' YearPicker title format string
yearPicker.titleFormatter function function (year) {} YearPicker title formatter function
yearPicker.onSelect event function (year) {} Called when year select by user
onSelect event function (unixDate) {} Called when date Select by user.
onSet event function (unixDate) {} Called when date Select by api.
onShow event function () {} Called when datePicker shown
onHide event function () {} Called when datePicker hidden
onToggle event function () {} Called when datePicker visibility toggle
onDestroy event function () {} Called when datePicker destroyed
autoClose boolean false If true datePicker close after select date
position string 'auto' Position of datepicker element relative to input element, accept 'auto', [x,y]
observer boolean false If true datepicker update self by user inputted date string, accept 'yyyy/mm/dd'
inputDelay int 800 (millisecond) Time for last user key-down event, accept millisecond
template string null By default datepicker have a template string, and you can overwrite it simply by replace string in config.

license

Freely distributable under the terms of the MIT license.

pwt.datepicker's People

Contributors

babakhani avatar balupton avatar dariushahmadi avatar hramezani avatar jamalsayedi avatar mammad2c avatar mj-vakili avatar mort3za avatar nik-kashi avatar saeedsajadi avatar ysmoradi 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

pwt.datepicker's Issues

DatePicker does not trigger the change event

I'm using the component in an angularjs application and the bindings are broken because the component is not firing/triggering neither then change nor the input event on the element.
I've made a temporary fix by using the onSelect callback, but this can be handled better from the source.

If anybody needs it, here's my ngDirective:

var linker = function(config) {
  return {
    restict: 'A',
    link: function(scope, element, attrs) {
      config = ng.extend({
        persianDigit: false
      }, config);

      var _onSelect = config.onSelect;
      config.onSelect = function(t) {
        element.trigger('change');
        if(_onSelect) _onSelect.apply(this, arguments);
      };

      element.pDatepicker(config);
    }
  };
};

Your Plugin not support in IE8 .

سلام دوست عزیز ، ممنون از زحمتی که کشیدی ولی متاسفانه در آی ای 8 اجرا نمی شه ، آی ای 7 اجرا نشه مهم نیست زیاد ولی هنوز خیلی از کاربران ایرانی از آی ای 8 استفاده می کنند .
من یه 2 ساعتی جسارتا به کدهای شما ور رفتم ولی خوب نتونستم از منطقش سر در بیارم.
لطف بزرگی می کنید این باگ رو رفع کنید چون من خیلی به اجرای صحیح پلاگن شما در آی ای 8 نیاز دارم.

ارادتمند ، امین قادری.

Add methods for getting the selected date

I think it would be a good idea to include methods for obtaining the selected date.

Currently, in order to get the date you either have to manually set a variable in the onSelect event or use $(element).val().
Using $(element).val() is inconvenient as it returns the format in which the date is being displayed which is usually different from the format needed for processing (e.g. sending ajax requests)

My suggestion is methods such as these:

$(element).pDatepicker('unixDate'); 
$(element).pDatepicker('format', 'YYYY/MM/DD); 

error in setDate method

setDate method make changes correctly but setDate calls this.setTime(). In setTime method, this.timePicker.setTime is undefined. Seems that this.timePicker is the config object not ClassTimePicker object.

I called setDate as this: $('.selector').pDatepicker('setDate', [1393,1,1])

Broken resource links upon package upgrade

You have a great package and I really appreciate that you've published it to bower, but appending the version number to the compiled scripts is not a good practice.
Consider the scenario where a consumer tries to update the package; all the links and configurations need to be updated in that case, which can be simply avoided.

I would also suggest using Require.js to define the package instead of using globals.

Type date from right to left

It's ok to type the date from right to left in persian style. for example:

i interest to type my birthdate as 15/06/1361

it will be show:

0000/00/00 < 15/
0000/00/15 < 06/
0000/06/15 < 1361
1361/06/05

Bingo !

thanks for your considerations

setTime method throwing error

I'm doing this:

  $(".example1").
    pDatepicker().
    pDatepicker("setDate",[1333,3,3,3,3] ).
    pDatepicker( "show" );

And I see this error:
Uncaught TypeError: this.timePicker.setTime is not a function ClassDatepicker.setTime @ persian-datepicker-0.4.5.js:2229

FR: set input value

I want to set input element value as null on page load. by default it will be set to the current date.

افزودن فانکشن ست کردن تاریخ

سلام آقای باباخانی،
تقویم بسیار عالی و کاربردیه و استایل بوت اسرپ هم زیباترش کرده فقط در صورت امکان در هنگام اینیشیالایز تقویم فانکشن ست کردن تاریخ رو هم اضافه کنین.
ممنون

TODO

Remove Jquery tmpl
add method:
show,hide,destroy,dialog,option,refresh,setDate

add method

can you add method we can get current selected date in it like:
$(datepicker selection).getSelectedDate();
and add keyboard navigation to it we can use arrow key

BUG: invalid date format

in demo example, when the format is defined as

format: 'YYYY/MM/DD'

after refreshing the page (F5), date will be corrupted.

bower package

Is there any bower package registered for this project ?
i can't find any sign of this on current github project or official documentation .
so can you please add a bower package ?

http://bower.io/docs/creating-packages/#register

(or) if you don't mind i can add a bower package but there will be the question of keeping it up to date .

thanks

Set Date With json

Hi Reza,
I wanna Set date with json data but it seems we can not do that , can u Dive some advice???

Wrong value

Hello Reza,

Whenever a Persian date is set in the text-box, it doesn't recognize it properly and display wrong date... I think you assumed given date should be in Gregorian Date while I need to set it in Jalalian-Date. I guess it is better to provide a config or in smart way detect intelligently given value is persian or gregorian...

By the way, this behavior is not included in previous version.

Also I attached a screenshot of this error.

Thanks for your efforts :)

image

$.tmpl

Hello,

Might you please rename your micro-template naming from $.tmpl to anything else?
It causes many problems in the systems that its other modules use jquery as their template engine, actually because you overrode default behavior, other modules doesn't work properly...

Thanks again

negative year

There should not be a choice in the negative year.
Be grateful if this error fix.

مشکل در minDate و maxDate

سلام
تو آخرین ورژنی که گذاشتید
من یه minDate ست کردم و مقدارش ماه آبان سال 1388 هست
تو سال 88 فقط ماه آبان فعال میشه و بعد از اون غیر فعاله مقدار timestamp هم مقدار زیره

1258675200000
موفق باشید

little bug

Hi.
I'm using your great date/time picker but I faced a little bug!I'm using ubuntu 14.4 and system date time format is 24H, and for example at 16:05 the time picker shows 16:05 PM not 4:05 PM

Don't change the input value at init

Hi
I think if there was a way not changing the input value at first init call would really help because in this way we loose our placeholder or something like that

It won't close using jquery-2.0.3

Hi
Thanks for your great work.
I use Jquery 2.0.3 and jquery ui 1.10.3
there are two problems i accorded with.

  1. after clicking outside of date picker window, it doesn't close the window.
  2. in jquery ui dialog, it appears behind the window and it's not clickable.
    thanks

ENORESTARGET error installing through bower

Recently I've tried to update my bower libraries. But there is a problem when bower try to update persian-datepicker (ENORESTARGET).

I tried to install a fresh one, but that error still remains:

bower install persian-datepicker --save
bower persian-datepicker#*      cached git://github.com/babakhani/pwt.datepicker.git#0.4.0
bower persian-datepicker#*    validate 0.4.0 against git://github.com/babakhani/pwt.datepicker.git#*
bower persian-date#~1.7.0   not-cached git://github.com/babakhani/PersianDate.git#~1.7.0
bower persian-date#~1.7.0      resolve git://github.com/babakhani/PersianDate.git#~1.7.0
bower persian-date#~1.7.0 ENORESTARGET No tag found that was able to satisfy ~1.7.0

Additional error details:
Available versions: 0.1.8

Format Error

Hello,

There is a bug at line number 117 in datepicker.js that is saying format is not valid function...

Screenshot is attached

Thanks

image

The setDate Method works incorrectly !!

there is a problem with setDate Method in your calendar ..
for example when i use the : $("#example1" ).pDatepicker("setDate","2015,12,24,11,11" );

the input text shows the date : 772-11-14 12:42:48 PM date !!

Init date with input value?!

I set HTML input value, but when datapicker runs shows today date!!!

show me an example for set input date by html input value before datapicker loads.
dp

فارسی:
وقتی به فرم مقدار میدم، مقدار رو نادیده می گیره و تاریخ امروز رو می زنه
می خوام مقدار بگیره، برای بخش ویرایش مطلب لازم دارم مقدار بگیره!!!

Move With Scroll?

When box appears in page if you scroll the page, calendar will scroll to up to down, beside it has the absolute position !!!

تقویم

با سلام و خسته نباشید
آقای باباخانی این تقویمی که طراحی کرده اید بسیار عالی هست.

من به یک مورد در بر خوردم که تا حالا نتوانستم آن را حل کنم.
وقتی تایم پیکر فراخوانی می شود و زمان ذخیره می شود ، هنگامی که دوباره به آن مراجعه می شود(جهت ویرایش) - ساعت حال در تکست باکس قرار می گیرد و ساعتی که ذخیره شده را نمایش نمی دهد
من ابتدا فکر کردم مربوط به فرمت انتخابی هست اما بعد متوجه شدم که هیچ فرمتی را نمایش نمی دهد و زمان حال را نمایش می دهد.

مورد دوم: وقتی تاریخ را ذخیره می کنم که به صورت جلالی ذخیره می شود - برای بار دوم که به آن مراجعه می شود(برای ویرایش)نیاز دارد که تاریخ را به میلادی تبدیل و ذخیره کنیم تا هنگام فراخوانی مجدد تقویم آن را درست نمایش دهد.اگر راهی پیدا کنید که در تکست باکس تقویم را جلالی نمایش و هنگام ذخیره شدن آن را میلادی ذخیره کند بسیار عالی می شود(هماهنگی با پایگاه داده) یا اینکه یک کانفیگ برای انتخاب نوع ورودی (جلالی یا میلادی)در نظر بگیرید بهتر می شود.

اگرازعنوان دیت تایم پیکر برای تقویم استفاده کنید در جستجوی گوگل راحت تر پیدا می شود

مورد بعدی : اگر از بوت راست چین شده استفاده شود جهت های >< هم جابجا می شود

مورد مهم تر اگر برای تقویم یک تارگتی در نظر بگیرید تا وقتی روی دکمه کلیک شد تقویم نمایش داده شود و بعد از انتخاب تاریخ تقویم بسته شود و نتیجه در تکست باکس ذخیره شود.یک نگاهی به تقویم زیر بیندازید

http://eonasdan.github.io/bootstrap-datetimepicker/

از مومنت استفاده کرده

از شما بابت طراحی چنین تقویم خوبی سپاس گذارم و منتظر پاسخ شما هستم

Value

Hello Reza,

Thanks for such an admirable work.

But there is a bug I guess. If a Persian value is set in the text-box, when you get that value by a selector, or during a serialization (such as form serialization in case of ajax posting), the value that is returned is not actual date/time value and is its Persian (Unicode) corresponded. you can find it in the following screen shot.

I think the feature that you convert normal digits to Persian ones is very great, but I think you shouldn't change the plain value in the text-box's value (Convert to Unicode).

Great thanks again for your all efforts... :)

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.