Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bypass events to jQuery UI Datepicker #25

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
jqModal Changes By Release
==========================

## 1.4.2 (2016.04.24 +r27.1)
* allow exclusions for elements which are children of .blockMsg

## 1.4.2 (2016.04.16 +r27)

* restore parsing and assigning closeClass behavior in ajax loaded content
Expand Down
19 changes: 14 additions & 5 deletions jqModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* $Version: 1.4.2 (2016.04.16 +r27)
* $Version: 1.4.2 (2016.04.16 +r27a, patched)
* Requires: jQuery 1.2.3+
*/

Expand Down Expand Up @@ -318,9 +318,16 @@
}, X = function(e){
// X: The Focus Examination Function (for modal: true dialogs)

var targetModal = $(e.target).data('jqm') ||
$(e.target).parents('.jqm-init:first').data('jqm');
var activeModal = ActiveModals[ActiveModals.length-1];
var $target = $(e.target),
targetModal = $target.data('jqm') ||
$target.parents('.jqm-init:first').data('jqm');
var activeModal = ActiveModals[ActiveModals.length-1],
activeModalOpts = $(activeModal).data('jqm');

// allow all elements with parents.blockMsgClass (used for jqui datepicker)
if ($target.parents('.'+activeModalOpts.blockMsgClass).length > 0) {
return true;
}

// allow bubbling if event target is within active modal dialog
return (targetModal && targetModal.ID === activeModal._jqmID) ?
Expand Down Expand Up @@ -356,6 +363,7 @@
* (Function) onShow - User defined callback function fired when modal opened.
* (Function) onHide - User defined callback function fired when modal closed.
* (Function) onLoad - User defined callback function fired when ajax content loads.
* (String) blockMsgClass- User defined exclusion parent class which are allowed to get focus even outside the active modal (like the jQueryUI datepicker)
Copy link
Owner

@briceburg briceburg Apr 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dpesch lets call this modalAllow instead of blockMsgClass -- and support (Mixed) instead of a (String) class. -- This way we can use .closest (https://api.jquery.com/closest/) which is faster and suppports a string match, an element, or collection.

e.g.

// original support
$(e).jqm({modal: true, modalAllow: '.blockMsg'});  

// or more flexible support
$(e).jqm({modal: true, modalAllow: '#blockMsg'});  
$(e).jqm({modal: true, modalAllow: document.getElementByID('blockMsg')});   //etc. then....

// override modal behavior if modalAllow is provided and matches target or an ancestor of target
if (activeModalOpts.modalAllow && $target.closest(activeModalOpts.modalAllow).length > 0) {
  return true;
}

*/
params: {
overlay: 50,
Expand All @@ -370,7 +378,8 @@
toTop: false,
onShow: onShow,
onHide: onHide,
onLoad: false
onLoad: false,
blockMsgClass: 'blockMsg'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dpesch I'd prefer not to have any side effects. lets default this to null and conditionally apply the $.target.parents match (https://github.com/briceburg/jqModal/pull/25/files#diff-63a527e6356eabc413f23b70fb806783R328) if its not null.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great, I've used blockMsgClass to let it compatible to jquery blockUI, but your idea look much better

},

// focusFunc is fired:
Expand Down