Skip to content

Commit a771d62

Browse files
committed
Add nonStackable setting for nmObject
Add isStackable function for nmObject Use this new setting to create the new nmObject for element binded in a modal
1 parent b4a65e2 commit a771d62

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

js/jquery.nyroModal.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jQuery(function($, undefined) {
2424
closeButton: '<a href="#" class="nyroModalClose nyroModalCloseButton nmReposition" title="close">Close</a>', // Close button HTML
2525

2626
stack: false, // Indicates if links automatically binded inside the modal should stack or not
27+
nonStackable: 'form', // Filter to not stack DOM element
2728

2829
header: undefined, // header include in every modal
2930
footer: undefined, // footer include in every modal
@@ -158,9 +159,9 @@ jQuery(function($, undefined) {
158159
},
159160

160161
// Get the nmObject for a new nyroModal
161-
getForNewLinks: function() {
162+
getForNewLinks: function(elt) {
162163
var ret;
163-
if (this.stack) {
164+
if (this.stack && (!elt || this.isStackable(elt))) {
164165
ret = $.extend(true, {}, this);
165166
ret._nmOpener = undefined;
166167
ret.elts.all = undefined;
@@ -173,6 +174,11 @@ jQuery(function($, undefined) {
173174
ret._open = false;
174175
return ret;
175176
},
177+
178+
// Indicate if an element can be stackable or not, regarding the nonStackable setting
179+
isStackable: function(elt) {
180+
return !elt.is(this.nonStackable);
181+
},
176182

177183
// key handle function.
178184
// Will call 'keyHandle' callback filter
@@ -800,7 +806,10 @@ jQuery(function($, undefined) {
800806
},
801807
beforeShowCont: function(nm) {
802808
nm.elts.cont
803-
.find('.nyroModal').nyroModal(nm.getForNewLinks(), true).end()
809+
.find('.nyroModal').each(function() {
810+
var cur = $(this);
811+
cur.nyroModal(nm.getForNewLinks(cur), true);
812+
}).end()
804813
.find('.nyroModalClose').bind('click.nyroModal', function(e) {
805814
e.preventDefault();
806815
nm.close();

0 commit comments

Comments
 (0)