Skip to content

Commit

Permalink
Merge pull request #57 from benjamin-albert/master
Browse files Browse the repository at this point in the history
Fixes #53 by using the mousedown event to close the menu
  • Loading branch information
KidSysco committed Apr 19, 2016
2 parents 29f0250 + ee7bf07 commit ea793f9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: node_js
node_js:
- "0.12.4"
- "5.10.1"
before_install: npm install -g grunt-cli
install: npm install
2 changes: 1 addition & 1 deletion demo/MonthPicker.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jquery-ui-month-picker",
"description": "jQuery UI Month Picker Plugin",
"version": "3.0.0",
"version": "3.0.1",
"license": "GPL-3.0",
"repository": "https://github.com/KidSysco/jquery-ui-month-picker.git",
"scripts": {
Expand All @@ -10,6 +10,7 @@
},
"devDependencies": {
"bower": "",
"grunt": "^1.0.1",
"grunt-contrib-cssmin": "^0.14.0",
"grunt-contrib-qunit": "^0.6.0",
"grunt-contrib-uglify": "~0.6.0",
Expand Down
5 changes: 2 additions & 3 deletions src/MonthPicker.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
The jQuery UI Month Picker Version 3.0.0
The jQuery UI Month Picker Version 3.0.1
https://github.com/KidSysco/jquery-ui-month-picker/
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Expand All @@ -14,9 +14,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see
along with this program. If not, see
<http://www.gnu.org/licenses/gpl-3.0.txt>.
*/

.month-picker {
Expand Down
25 changes: 12 additions & 13 deletions src/MonthPicker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
The jQuery UI Month Picker Version 3.0.0
The jQuery UI Month Picker Version 3.0.1
https://github.com/KidSysco/jquery-ui-month-picker/
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Expand All @@ -14,9 +14,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see
along with this program. If not, see
<http://www.gnu.org/licenses/gpl-3.0.txt>.
*/

(function ($, window, document, Date) {
Expand Down Expand Up @@ -167,7 +166,7 @@ along with this program. If not, see
}

$.MonthPicker = {
VERSION: '3.0.0', // Added in version 2.4;
VERSION: '3.0.1', // Added in version 2.4;
i18n: {
year: 'Year',
prevYear: 'Previous Year',
Expand Down Expand Up @@ -441,8 +440,8 @@ along with this program. If not, see

this._buttons = $('a', $table).jqueryUIButton();

_menu.on(click, function (event) {
return false;
_menu.on('mousedown' + _eventsNs, function (event) {
event.preventDefault();
});

// Checks and initailizes Min/MaxMonth properties
Expand Down Expand Up @@ -542,7 +541,7 @@ along with this program. If not, see
// Allow the user to prevent opening the menu.
event = event || $.Event();
if (_event('OnBeforeMenuOpen', this)(event) === false || event.isDefaultPrevented()) {
return false;
return;
}

this._visible = true;
Expand All @@ -561,8 +560,7 @@ along with this program. If not, see
}

_openedInstance = this;

$(document).on(click + this.uuid, $proxy(this.Close, this))
$(document).on('mousedown' + _eventsNs + this.uuid, $proxy(this.Close, this))
.on('keydown' + _eventsNs + this.uuid, $proxy(this._keyDown, this));

// Trun off validation so that clicking one of the months
Expand All @@ -584,8 +582,6 @@ along with this program. If not, see
});
}
}

return false;
},

Close: function (event) {
Expand All @@ -609,7 +605,7 @@ along with this program. If not, see
this._visible = false;
_openedInstance = null;
$(document).off('keydown' + _eventsNs + this.uuid)
.off(click + this.uuid);
.off('mousedown' + _eventsNs + this.uuid);

this.Validate();
_elem.on('blur' + _eventsNs, $proxy(this.Validate, this));
Expand Down Expand Up @@ -718,7 +714,10 @@ along with this program. If not, see
$(this).insertAfter(_elem);
}
})
.on(click, $proxy(this.Toggle, this));
.on(click, $proxy(this.Toggle, this))
.on('mousedown' + _eventsNs, function(r) {
r.preventDefault();
});

if (this._removeOldBtn) {
_oldButton.remove();
Expand Down

0 comments on commit ea793f9

Please sign in to comment.