Skip to content

Commit 83d84ab

Browse files
committed
KeyboardEnabled now doesn't work when input elements are focused in modal.
1 parent 3dc58d8 commit 83d84ab

File tree

9 files changed

+46
-46
lines changed

9 files changed

+46
-46
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
### ![jquery-confirm](https://raw.githubusercontent.com/craftpip/jquery-confirm/master/jquery-confirm.png "jquery-confirm")
22
*alerts, confirms and dialogs in* ***one.***
33

4-
v1.7.8
4+
v1.7.9
55

66
A multipurpose plugin for alert, confirm & dialog, with Super powers.
77

@@ -54,6 +54,9 @@ Checkout the [documentation](http://craftpip.github.io/jquery-confirm) for furth
5454

5555
## Version changes
5656

57+
(New in 1.7.9)
58+
* Minor bug fixes
59+
5760
(New in 1.7.8)
5861
* RTL support
5962
* Option to select keyboard keys

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jquery-confirm2",
3-
"version": "1.7.8",
3+
"version": "1.7.9",
44
"homepage": "https://github.com/craftpip/jquery-confirm",
55
"authors": [
66
"boniface pereira <bonifacepereira@gmail.com>"

css/jquery-confirm.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* jquery-confirm v1.7.8 (http://craftpip.github.io/jquery-confirm/)
2+
* jquery-confirm v1.7.9 (http://craftpip.github.io/jquery-confirm/)
33
* Author: boniface pereira
44
* Website: www.craftpip.com
55
* Contact: hey@craftpip.com

css/jquery-confirm.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* jquery-confirm v1.7.8 (http://craftpip.github.io/jquery-confirm/)
2+
* jquery-confirm v1.7.9 (http://craftpip.github.io/jquery-confirm/)
33
* Author: boniface pereira
44
* Website: www.craftpip.com
55
* Contact: hey@craftpip.com

dist/jquery-confirm.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jquery-confirm.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<script src="demo/libs/bootstrap.min.js"></script>
3636
<script src="demo/libs/pretty.js"></script>
3737
<script>
38-
var version = '1.7.8';
38+
var version = '1.7.9';
3939
</script>
4040
<style type="text/css">
4141
.space10{

js/jquery-confirm.js

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* jquery-confirm v1.7.8 (http://craftpip.github.io/jquery-confirm/)
2+
* jquery-confirm v1.7.9 (http://craftpip.github.io/jquery-confirm/)
33
* Author: Boniface Pereira
44
* Website: www.craftpip.com
55
* Contact: hey@craftpip.com
@@ -17,20 +17,20 @@ var jconfirm, Jconfirm;
1717
"use strict";
1818
$.confirm = function (options) {
1919
/*
20-
* Alias of jconfirm
20+
* Alias of jconfirm
2121
*/
2222
return jconfirm(options);
2323
};
2424
$.alert = function (options) {
2525
/*
26-
* Alias of jconfirm
26+
* Alias of jconfirm
2727
*/
2828
options.cancelButton = false;
2929
return jconfirm(options);
3030
};
3131
$.dialog = function (options) {
3232
/*
33-
* Alias of jconfirm
33+
* Alias of jconfirm
3434
*/
3535
options.cancelButton = false;
3636
options.confirmButton = false;
@@ -92,18 +92,18 @@ var jconfirm, Jconfirm;
9292
'-webkit-transition-duration': this.animationSpeed / 1000 + 's',
9393
'transition-duration': this.animationSpeed / 1000 + 's',
9494
'-webkjit-transition-timing-function': 'cubic-bezier(0.27, 1.12, 0.32, ' + this.animationBounce + ')',
95-
'transition-timing-function': 'cubic-bezier(0.27, 1.12, 0.32, ' + this.animationBounce + ')',
95+
'transition-timing-function': 'cubic-bezier(0.27, 1.12, 0.32, ' + this.animationBounce + ')'
9696
};
9797

9898
this.$el.find('.jconfirm-bg').css(this.CSS);
9999
this.$b = this.$el.find('.jconfirm-box').css(this.CSS).addClass(this.animation);
100100

101101
/*
102-
* Add rtl class if rtl option has selected
103-
*/
102+
* Add rtl class if rtl option has selected
103+
*/
104104
if (this.rtl)
105105
this.$el.addClass("rtl");
106-
106+
107107
/*
108108
* Setup title contents
109109
*/
@@ -115,25 +115,21 @@ var jconfirm, Jconfirm;
115115
*/
116116
this.$btnc = this.$el.find('.buttons');
117117
if (this.confirmButton && this.confirmButton.trim() !== '') {
118-
this.$confirmButton = $('<button class="btn">' + this.confirmButton + '</button>')
119-
.appendTo(this.$btnc)
120-
.addClass(this.confirmButtonClass);
118+
this.$confirmButton = $('<button class="btn">' + this.confirmButton + '</button>').appendTo(this.$btnc).addClass(this.confirmButtonClass);
121119
}
122120
if (this.cancelButton && this.cancelButton.trim() !== '') {
123-
this.$cancelButton = $('<button class="btn">' + this.cancelButton + '</button>')
124-
.appendTo(this.$btnc)
125-
.addClass(this.cancelButtonClass);
121+
this.$cancelButton = $('<button class="btn">' + this.cancelButton + '</button>').appendTo(this.$btnc).addClass(this.cancelButtonClass);
126122
}
127123

128124
if (!this.confirmButton && !this.cancelButton) {
129125
this.$btnc.remove();
130126
}
131127

132-
if(!this.confirmButton && !this.cancelButton && this.closeIcon == null){
128+
if (!this.confirmButton && !this.cancelButton && this.closeIcon == null) {
133129
this.$closeButton = this.$b.find('.closeIcon').show();
134130
}
135131

136-
if (this.closeIcon === true){
132+
if (this.closeIcon === true) {
137133
this.$closeButton = this.$b.find('.closeIcon').show();
138134
}
139135

@@ -142,7 +138,7 @@ var jconfirm, Jconfirm;
142138
if (this.autoClose)
143139
this._startCountDown();
144140
},
145-
setTitle: function(string){
141+
setTitle: function (string) {
146142
this.title = (typeof string !== 'undefined') ? string : this.title;
147143

148144
if (this.title) {
@@ -161,8 +157,7 @@ var jconfirm, Jconfirm;
161157
*/
162158
if (typeof this.content === 'boolean') {
163159
if (!this.content)
164-
this.contentDiv.remove();
165-
else
160+
this.contentDiv.remove(); else
166161
console.error('Invalid option for property content: passed TRUE');
167162
} else if (typeof this.content === 'string') {
168163

@@ -229,10 +224,10 @@ var jconfirm, Jconfirm;
229224
_bindEvents: function () {
230225
var that = this;
231226
var boxClicked = false;
232-
227+
233228
this.$el.find('.jconfirm-scrollpane').click(function (e) {
234229
// ignore propagated clicks
235-
if (!boxClicked) {
230+
if (!boxClicked) {
236231
// background clicked
237232
if (that.backgroundDismiss) {
238233
that.cancel();
@@ -246,11 +241,11 @@ var jconfirm, Jconfirm;
246241
}
247242
boxClicked = false;
248243
});
249-
244+
250245
this.$el.find('.jconfirm-box').click(function (e) {
251246
boxClicked = true;
252247
});
253-
248+
254249
if (this.$confirmButton) {
255250
this.$confirmButton.click(function (e) {
256251
e.preventDefault();
@@ -293,15 +288,19 @@ var jconfirm, Jconfirm;
293288

294289
},
295290
reactOnKey: function key(e) {
296-
291+
297292
/*
298-
* prevent keyup event if the dialog is not last!
293+
* prevent keyup event if the dialog is not last!
299294
*/
300295
var a = $('.jconfirm');
301296
if (a.eq(a.length - 1)[0] !== this.$el[0])
302297
return false;
303298

304299
var key = e.which;
300+
// Do not react if Enter/Space is pressed on input elements
301+
if (this.$b.find(':input').is(':focus') && /13|32/.test(key))
302+
return false;
303+
305304
if ($.inArray(key, this.cancelKeys) !== -1) {
306305
/*
307306
* Cancel key pressed.
@@ -326,8 +325,6 @@ var jconfirm, Jconfirm;
326325
*/
327326
if (this.$confirmButton) {
328327
this.$confirmButton.click();
329-
} else {
330-
331328
}
332329
}
333330
},
@@ -339,11 +336,11 @@ var jconfirm, Jconfirm;
339336
if (boxHeight > (windowHeight - minMargin)) {
340337
var style = {
341338
'margin-top': minMargin / 2,
342-
'margin-bottom': minMargin / 2,
339+
'margin-bottom': minMargin / 2
343340
}
344341
} else {
345342
var style = {
346-
'margin-top': topMargin,
343+
'margin-top': topMargin
347344
}
348345
}
349346
if (animate) {
@@ -358,10 +355,10 @@ var jconfirm, Jconfirm;
358355
close: function () {
359356
var that = this;
360357

361-
if(this.isClosed())
358+
if (this.isClosed())
362359
return false;
363360

364-
if(typeof this.onClose === 'function')
361+
if (typeof this.onClose === 'function')
365362
this.onClose();
366363
/*
367364
unbind the window resize & keyup event.
@@ -380,7 +377,7 @@ var jconfirm, Jconfirm;
380377
jconfirm.record.closed += 1;
381378
jconfirm.record.currentlyOpen -= 1;
382379

383-
if(jconfirm.record.currentlyOpen < 1)
380+
if (jconfirm.record.currentlyOpen < 1)
384381
$('body').removeClass('jconfirm-noscroll');
385382

386383
return true;
@@ -401,7 +398,7 @@ var jconfirm, Jconfirm;
401398
this.$b.find('input[autofocus]:visible:first').focus();
402399
jconfirm.record.opened += 1;
403400
jconfirm.record.currentlyOpen += 1;
404-
if(typeof this.onOpen === 'function')
401+
if (typeof this.onOpen === 'function')
405402
this.onOpen();
406403
return true;
407404
},
@@ -438,17 +435,17 @@ var jconfirm, Jconfirm;
438435
autoClose: false,
439436
closeIcon: null,
440437
columnClass: 'col-md-6 col-md-offset-3',
441-
onOpen: function(){
438+
onOpen: function () {
442439
},
443-
onClose: function(){
440+
onClose: function () {
444441
},
445-
onAction: function(){
442+
onAction: function () {
446443
}
447444
};
448445

449446
jconfirm.record = {
450447
opened: 0,
451448
closed: 0,
452-
currentlyOpen: 0,
449+
currentlyOpen: 0
453450
};
454451
})(jQuery);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jquery-confirm",
3-
"version": "1.7.8",
3+
"version": "1.7.9",
44
"title": "jquery-confirm.js | A multipurpose alert and confirm plugin",
55
"description": "A jQuery plugin that provides great set of features like, Auto-close, Ajax-loading, background-dismiss, themes and more.",
66
"homepage": "http://craftpip.github.io/jquery-confirm/",

0 commit comments

Comments
 (0)