Skip to content

Adds MonthFormat and Animation options + GetSelectedDate and Validate methods#17

Merged
KidSysco merged 22 commits into
KidSysco:masterfrom
benjamin-albert:master
Oct 8, 2015
Merged

Adds MonthFormat and Animation options + GetSelectedDate and Validate methods#17
KidSysco merged 22 commits into
KidSysco:masterfrom
benjamin-albert:master

Conversation

@benjamin-albert
Copy link
Copy Markdown
Collaborator

Hi,

This is a pull request for #16.

I've added a couple of new options:

  • MonthFormat which uses $.datepicker.formatDate() and $.datepicker.parseDate() to format, parse and create the input mask. You can also use a third party library for parsing and formatting (see the new README.md).
  • Animation which allows you to specify the animation to use in both opening and closing the menu, but I also included ShowAnim and HideAnim for consistency with datepciker and to allow you to have different animations for opening and closing the menu.
  • Duration which allows specifying the animations speed.

I've also added some new methods:

  • GetSelectedDate which return the month as a JavaScript Date object.
  • Validate an alternative for GetSelectedMonthYear which validates the input and return the selected month as a JavaScript Date object.

I've also added some usability features:

  • The default animation is fadeToggle and the default speed is 400ms (to match datepicker's behavior).
  • Pressing escape hides the menu.
  • Pressing enter selects the current month.

All events this new refer to the associated input field, it would be grate if you can add some tests for $(this)....

When I first added the new code to the new fiddle I broke a GetSelectedMonthYear unit test that tested that the return value was '2/2012' and the new code was returning '02/2012' (because I was using the MonthFormat option).

I have to admit that when I first refactored this method I thought it use to be a private method that was made public because It had all of that validate code which I thought had nothing to do with the method.

But when I first looked at the documentation I was surprised because:

  • The name is misleading. There's no way someone how didn't read the docs will know that method performs visual validation.
  • Except for comparing the value a with specific string the value returned is kind of useless.
  • The docs say it focuses on the invalid value but I did't see anything like that in the code (perhaps we should remove this from the docs until we actually implement this).

So I added the Validate method which I believe better reflects what it does and returns a Date that you can interact with and get exactly what you want out of it without having to parse a string or use the lengthy GetSelectedMonth and GetSelectedYear methods.

I would appreciate it if you can look at my new documentation and tell me if I have any typos (my spelling isn't perfect).

benjamin-albert and others added 18 commits September 30, 2015 22:18
user to specify which jQuery (not jQuery UI effects) animation
method they want to use.
format for parsing and displaying dates.
Makes all callbacks this refer to the the input element +
Makes UseInputMask option aware of the MonthFormat option +
Allows using a third party library for parsing and fromating months +
Added var delecration in various methods to help uglify
with name mangling
Makes </script> tags visible in the README.md (I checked it you
now just copy and paste the tags and the plugin will work).
@KidSysco
Copy link
Copy Markdown
Owner

KidSysco commented Oct 5, 2015

Benjamin! You are a rock star! I was out of town on travel all weekend and just got back. Give me a few days to soak this up then I will probably merge it in.

Keep it coming if you got more!

THANKS!

@benjamin-albert benjamin-albert changed the title Adds MonthFormat and Animation options + GetSelectedYear and Validate methods Adds MonthFormat and Animation options + GetSelectedDate and Validate methods Oct 5, 2015
@KidSysco
Copy link
Copy Markdown
Owner

KidSysco commented Oct 5, 2015

Nice fiddle you put together! Thats great! Woot! I love your work!

@benjamin-albert
Copy link
Copy Markdown
Collaborator Author

I'm glad to hear you're excited about my work.

I've just finished implementing the rest of the features in #16 you can take a look at the 2.5 branch in my fork.

I'll open a pull request with all the details when I finish testing, writing documentation and creating a fiddle.

@KidSysco
Copy link
Copy Markdown
Owner

KidSysco commented Oct 8, 2015

I really like the Date Picker formatting and parsing. That is some great work that really shows strong understanding of the jQuery UI internals. I saw you did some extra work there to ensure unit tests were not broken, that is great work too. It is a pleasure to work with you Benjamin, you are a true professional. I am going to merge this and close it out now. Then I will update the fiddle.

KidSysco added a commit that referenced this pull request Oct 8, 2015
Adds MonthFormat and Animation options + GetSelectedDate and Validate methods
@KidSysco KidSysco merged commit 9113c35 into KidSysco:master Oct 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants