diff --git a/src/MonthPicker.css b/src/MonthPicker.css index bab158f..0353586 100644 --- a/src/MonthPicker.css +++ b/src/MonthPicker.css @@ -112,8 +112,9 @@ the button. This rule removes the unnecessary padding so the text in the jump years button will be vericaly centred. */ -.month-picker-year-table .ui-button-text { +.month-picker-year-table .ui-button-text, .month-picker-year-table .ui-button { padding: 0; + background: transparent; } .month-picker-month-table td { diff --git a/src/MonthPicker.js b/src/MonthPicker.js index d885db5..dfe8783 100644 --- a/src/MonthPicker.js +++ b/src/MonthPicker.js @@ -35,11 +35,12 @@ along with this program. If not, see // conflict with Bootstrap.js button (#35) $.widget.bridge('jqueryUIButton', $.ui.button); + var _isNewApi = $.ui.version >= '1.12'; var _speeds = $.fx.speeds; var _eventsNs = '.MonthPicker'; var _textfieldClass = 'month-year-input'; var _clearHint = 'month-picker-clear-hint'; - var _iconClass = '.ui-button-icon-primary'; + var _iconClass = (_isNewApi) ? '.ui-button-icon' : '.ui-button-icon-primary'; var _disabledClass = 'month-picker-disabled'; var _todayClass = 'ui-state-highlight'; var _selectedClass = 'ui-state-active'; @@ -141,23 +142,39 @@ along with this program. If not, see } } + function _prepareButtonOptions(opts) { + if (_isNewApi || opts == undefined) { + var newOpts = opts; + }else{ + var newOpts = {}; + if (opts.showLabel !== void 0) newOpts.text = opts.showLabel; + if (opts.icon !== void 0) newOpts.icons = {primary: opts.icon }; + if (opts.label !== void 0) newOpts.label = opts.label; + if (opts.disabled !== void 0) newOpts.disabled = opts.disabled; + } + return newOpts; + } + + $.fn.monthPickerButton = function(opts) { + return this.jqueryUIButton(_prepareButtonOptions(opts)); + }; + + $.fn.monthPickerButtonOption = function(opts) { + return this.jqueryUIButton('option', _prepareButtonOptions(opts)) + }; + function _makeDefaultButton(options) { // this refers to the associated input field. return $('' + options.i18n.buttonText + '') - .jqueryUIButton({ - text: false, - icons: { - // Defaults to 'ui-icon-calculator'. - primary: options.ButtonIcon - } + .monthPickerButton({ + showLabel: false, + icon: options.ButtonIcon }); } function _applyArrowButton($el, dir) { - $el.jqueryUIButton('option', { - icons: { - primary: 'ui-icon-circle-triangle-' + (dir ? 'w' : 'e') - } + $el.monthPickerButtonOption({ + icon: 'ui-icon-circle-triangle-' + (dir ? 'w' : 'e') }); } @@ -256,7 +273,7 @@ along with this program. If not, see function _setDisabled(_button, _value) { var _btnWidget = _button.data('ui-button'); - if (_btnWidget.option('disabled') !== _value) { + if (_value !== null && _btnWidget.option('disabled') !== _value) { _btnWidget.option('disabled', _value); } } @@ -410,19 +427,19 @@ along with this program. If not, see this._titleButton = $('.month-picker-title', _menu) .click($proxy(this._showYearsClickHandler, this)) - .find('a').jqueryUIButton() + .find('a').monthPickerButton() .removeClass(_defaultClass); this._applyJumpYearsHint(); this._createValidationMessage(); this._prevButton = $('.month-picker-previous>a', _menu) - .jqueryUIButton({ text: false }) - .removeClass(_defaultClass); + .monthPickerButton({ showLabel: false }) + .removeClass(_defaultClass); this._nextButton = $('.month-picker-next>a', _menu) - .jqueryUIButton({ text: false }) - .removeClass(_defaultClass); + .monthPickerButton({ showLabel: false }) + .removeClass(_defaultClass); this._setRTL(_opts.IsRTL); //Assigns icons to the next/prev buttons. @@ -438,7 +455,7 @@ along with this program. If not, see $tr.append('