Skip to content

Commit

Permalink
Add nonStackable setting for nmObject
Browse files Browse the repository at this point in the history
Add isStackable function for nmObject
Use this new setting to create the new nmObject for element binded in a modal
  • Loading branch information
nyroDev committed Jun 13, 2011
1 parent b4a65e2 commit a771d62
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions js/jquery.nyroModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jQuery(function($, undefined) {
closeButton: '<a href="#" class="nyroModalClose nyroModalCloseButton nmReposition" title="close">Close</a>', // Close button HTML

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

header: undefined, // header include in every modal
footer: undefined, // footer include in every modal
Expand Down Expand Up @@ -158,9 +159,9 @@ jQuery(function($, undefined) {
},

// Get the nmObject for a new nyroModal
getForNewLinks: function() {
getForNewLinks: function(elt) {
var ret;
if (this.stack) {
if (this.stack && (!elt || this.isStackable(elt))) {
ret = $.extend(true, {}, this);
ret._nmOpener = undefined;
ret.elts.all = undefined;
Expand All @@ -173,6 +174,11 @@ jQuery(function($, undefined) {
ret._open = false;
return ret;
},

// Indicate if an element can be stackable or not, regarding the nonStackable setting
isStackable: function(elt) {
return !elt.is(this.nonStackable);
},

// key handle function.
// Will call 'keyHandle' callback filter
Expand Down Expand Up @@ -800,7 +806,10 @@ jQuery(function($, undefined) {
},
beforeShowCont: function(nm) {
nm.elts.cont
.find('.nyroModal').nyroModal(nm.getForNewLinks(), true).end()
.find('.nyroModal').each(function() {
var cur = $(this);
cur.nyroModal(nm.getForNewLinks(cur), true);
}).end()
.find('.nyroModalClose').bind('click.nyroModal', function(e) {
e.preventDefault();
nm.close();
Expand Down

0 comments on commit a771d62

Please sign in to comment.