Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e47eb8f
Adds the Duration option which allows specifying the show/hide
benjamin-albert Sep 30, 2015
918296b
Merge remote-tracking branch 'origin/master'
benjamin-albert Sep 30, 2015
befca8c
Added Animation, ShowAnim and HideAnim options which allows the
benjamin-albert Sep 30, 2015
3a25847
Adds the MonthFormat option which allows specifying the
Oct 1, 2015
f7a9d0b
Makes the default animation options consistent with datepicker +
benjamin-albert Oct 2, 2015
67da55d
Makes perssing enter choose the current month + make escape close
benjamin-albert Oct 2, 2015
fe5d54f
Merge remote-tracking branch 'upstream/master'
benjamin-albert Oct 2, 2015
05e3035
Added documentation for new options + added a VERSION constant +
benjamin-albert Oct 2, 2015
5e880c4
Update README.md
benjamin-albert Oct 2, 2015
beb3ad0
Update README.md
benjamin-albert Oct 2, 2015
0a3079c
Update README.md
benjamin-albert Oct 2, 2015
ddc5ff0
Update README.md
benjamin-albert Oct 2, 2015
0cc0d06
Added since version 2.4 for new options
benjamin-albert Oct 2, 2015
abfb242
Fixed typos in MonthFormat documentation
benjamin-albert Oct 2, 2015
22b40cb
Update README.md
benjamin-albert Oct 2, 2015
2dd5b41
Removed repeated sentence in MonthFormat documentation
benjamin-albert Oct 2, 2015
a3d4f85
Fixed broken GetSelectdYear unit test and added an alternative
benjamin-albert Oct 2, 2015
892ac8d
Fixed broken GetSelectdYear unit test and added an alternative
benjamin-albert Oct 2, 2015
4393ab8
Merge remote-tracking branch 'origin/master'
benjamin-albert Oct 3, 2015
9d3a5fe
Added documenation for Duration option + fixed inccorect setter examples
benjamin-albert Oct 3, 2015
2a4f17a
Allows the user to disable a animations by passing in none
benjamin-albert Oct 3, 2015
8145dc4
Update README.md
benjamin-albert Oct 3, 2015
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
Prev Previous commit
Next Next commit
Added Animation, ShowAnim and HideAnim options which allows the
user to specify which jQuery (not jQuery UI effects) animation
method they want to use.
  • Loading branch information
benjamin-albert committed Sep 30, 2015
commit befca8c58233a8ad7feedfbf5aebd13a6b4ebddf
43 changes: 35 additions & 8 deletions MonthPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt.
var _defaultPos = { my: 'left top+1', at: 'left bottom' };
var _setupErr = 'MonthPicker Setup Error: ';
var _posErrr = _setupErr + 'The jQuery UI position plug-in must be loaded in order to specify a position.';
var _badOptValErr = _setupErr + 'Unsupported % option value, supported (case sensitive) values are: ';
var _animVals = {
Animation: ['slideToggle', 'fadeToggle'],
ShowAnim: ['fadeIn', 'slideDown'],
HideAnim: ['fadeOut', 'slideUp']
};

$.MonthPicker = {
i18n: {
Expand Down Expand Up @@ -89,6 +95,9 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt.
UseInputMask: false,
ValidationErrorMessage: null,
Disabled: false,
Animation: 'slideToggle',
ShowAnim: null,
HideAnim: null,
Duration: 500,
OnAfterMenuOpen: $.noop,
OnAfterMenuClose: $.noop,
Expand Down Expand Up @@ -158,7 +167,13 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt.
return;
}

// In jQuery UI 1.8, manually invoke the _setOption method from the base widget.
// Make sure the user passed in a valid Animation, ShowAnim and HideAnim options values.
if (key in _animVals && _animVals[key].indexOf(value) === -1) {
alert(_badOptValErr.replace(/%/, key) + _animVals[key]);
return;
}

// In jQuery UI 1.8, manually invoke the _setOption method from the base widget.
//$.Widget.prototype._setOption.apply(this, arguments);
// In jQuery UI 1.9 and above, you use the _super method instead.
this._super(key, value);
Expand Down Expand Up @@ -201,7 +216,7 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt.
return false;
}

var _el = this.element;
var _el = this.element, _opts = this.options;
// According to http://www.w3.org/TR/html-markup/input.html#input
// An input element with no type attribute specified represents the same thing as an
// input element with its type attribute set to "text".
Expand All @@ -218,16 +233,24 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt.
return false;
}

if (!jQuery.mask && this.options.UseInputMask) {
if (!jQuery.mask && _opts.UseInputMask) {
alert(_setupErr + 'The UseInputMask option is set but the Digital Bush Input Mask jQuery Plugin is not loaded. Get the plugin from http://digitalbush.com/');
return false;
}

if (this.options.Position !== null && !$.ui.position) {
if (_opts.Position !== null && !$.ui.position) {
alert(_posErrr);
return false;
}

// Make sure the user passed in a valid Animation, ShowAnim and HideAnim options values.
for (var opt in _animVals) {
if (_opts[opt] !== null && _animVals[opt].indexOf(_opts[opt]) === -1) {
alert(_badOptValErr.replace(/%/, opt) + _animVals[opt]);
return false;
}
}

this._isMonthInputType = _el.attr('type') === 'month';
if (this._isMonthInputType) {
_el.css('width', 'auto');
Expand Down Expand Up @@ -405,9 +428,9 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt.
this._setPickerYear(new Date().getFullYear());
}

var _menu = this._monthPickerMenu;
var _menu = this._monthPickerMenu, _opts = this.options;
if (_menu.css('display') === 'none') {
_menu.slideDown({
_menu[_opts.ShowAnim || _opts.Animation]({
duration: this._duration(),
start: $.proxy(this._position, this, _menu),
complete: $.proxy(this.options.OnAfterMenuOpen, this.options)
Expand Down Expand Up @@ -444,8 +467,12 @@ http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt.
},

_hide: function () {
if (this._monthPickerMenu.css('display') === 'block') {
this._monthPickerMenu.slideUp(this._duration(), $.proxy(this.options.OnAfterMenuClose, this.options));
var _menu = this._monthPickerMenu,
_opts = this.options;

if (_menu.css('display') === 'block') {
var _callback = $.proxy(this.options.OnAfterMenuClose, _opts);
_menu[_opts.HideAnim || _opts.Animation](this._duration(), _callback);
}
},

Expand Down
Loading