Skip to content

Commit 3fafa30

Browse files
committed
Update documentation in Readme file
Add swfObjectId settings and use it in filters.swf or create an uniq ID. Closes #1 Add recalc settings for nm.resize function to force the recalculation of the modal. Closes #9 Closes #46 Fix issue with jQuery 1.5 on IE8 (bogus selector in filters.swf). Closes #34 Fix stack error when reopening a modal. Closes #14 Add initFilters callbacks in order to force filters. Closes #28 Closes#37 Add afterReposition and afterUnreposition callbacks.
1 parent efbabe9 commit 3fafa30

3 files changed

Lines changed: 27 additions & 8 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ All function or callbacks receive the same nyroModal object as a unique paramete
190190
The list of all function or callback that can be called in a filter:
191191

192192
* is: should return true or false to select the filter for the current or element or not. This function is **REQUIRED** !
193+
* initFilters: called just after every filters have been determined to use or not, and just before the init of them. Good place to force filters.
193194
* init: called at the very beggining of the process. This function should bind element or create object needed later
194195
* initElts: called at the beggining of the open process, juste before the load start. After that, all the needed div are created and attached to the DOM
195196
* load: called only for ONE filter defined in nm.loadFilter attribute. This function should load the function and set it's content using the **_setCont** function
@@ -214,6 +215,8 @@ Like the version 1, there is a bunch of others callback that you can define befo
214215
* afterHideLoad: called just after the hideLoad animation
215216
* beforeShowCont: called just before the showCont animation (also called in case of a transition, before beforeHideTrans)
216217
* afterShowCont: called just after the showCont animation (also called in case of a transition, after afterHideTrans)
218+
* afterReposition: called just after the .nmRepositon have been placed
219+
* afterUnreposition: called just after the .nmRepositon have been replaced on theire initial positions
217220
* beforeHideCont: called just before the hideCont animation
218221
* afterHideCont: called just after the hideCont animation
219222
* beforeShowTrans: called just before the showTrans animation (transition)

js/jquery.nyroModal.filters.swf.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@
1111
jQuery(function($, undefined) {
1212
$.nmFilters({
1313
swf: {
14+
idCounter: 1,
1415
is: function(nm) {
15-
return nm._hasFilter('link') && nm.opener.is('[href$=.swf]');
16+
return nm._hasFilter('link') && nm.opener.is('[href$=".swf"]');
1617
},
1718
init: function(nm) {
1819
nm.loadFilter = 'swf';
1920
},
2021
load: function(nm) {
22+
if (!nm.swfObjectId)
23+
nm.swfObjectId = 'nyroModalSwf-'+(this.idCounter++);
2124
var url = nm.store.link.url,
22-
cont = '<div><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+nm.sizes.w+'" height="'+nm.sizes.h+'"><param name="movie" value="'+url+'"></param>',
25+
cont = '<div><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="'+nm.swfObjectId+'" width="'+nm.sizes.w+'" height="'+nm.sizes.h+'"><param name="movie" value="'+url+'"></param>',
2326
tmp = '';
2427
$.each(nm.swf, function(name, val) {
2528
cont+= '<param name="'+name+'" value="'+val+'"></param>';

js/jquery.nyroModal.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jQuery(function($, undefined) {
3838

3939
selIndicator: 'nyroModalSel', // Value added when a form or Ajax is sent with a filter content
4040

41+
swfObjectId: undefined, // Object id for swf object
4142
swf: { // Default SWF attributes
4243
allowFullScreen: 'true',
4344
allowscriptaccess: 'always',
@@ -93,6 +94,8 @@ jQuery(function($, undefined) {
9394
},
9495
// Open the modal
9596
open: function() {
97+
if (this._nmOpener)
98+
this._nmOpener._close();
9699
this.getInternal()._pushStack(this.opener);
97100
this._opened = false;
98101
this._bgReady = false;
@@ -104,7 +107,6 @@ jQuery(function($, undefined) {
104107
this._bgReady = true;
105108
if (this._nmOpener) {
106109
// fake closing of the opener nyroModal
107-
this._nmOpener._close();
108110
this._nmOpener._bgReady = false;
109111
this._nmOpener._loading = false;
110112
this._nmOpener._animated = false;
@@ -120,9 +122,17 @@ jQuery(function($, undefined) {
120122

121123
// Resize the modal according to sizes.initW and sizes.initH
122124
// Will call size function
123-
resize: function() {
124-
this.sizes.w = this.sizes.initW;
125-
this.sizes.h = this.sizes.initH;
125+
// @param recalc boolean: Indicate if the size should be recalaculated (useful when content has changed)
126+
resize: function(recalc) {
127+
if (recalc) {
128+
this.elts.hidden.append(this.elts.cont.children().first().clone());
129+
this.sizes.initW = this.sizes.w = this.elts.hidden.width();
130+
this.sizes.initH = this.sizes.h = this.elts.hidden.height();
131+
this.elts.hidden.empty();
132+
} else {
133+
this.sizes.w = this.sizes.initW;
134+
this.sizes.h = this.sizes.initH;
135+
}
126136
this._unreposition();
127137
this.size();
128138
this._callAnim('resize', $.proxy(function() {
@@ -400,9 +410,9 @@ jQuery(function($, undefined) {
400410
this._callFilters('beforeShowCont');
401411
this._callAnim('hideTrans', $.proxy(function() {
402412
this._transition = false;
413+
this._callFilters('afterShowCont');
403414
this.elts.cont.append(this._scriptsShown);
404415
this._reposition();
405-
this._callFilters('afterShowCont');
406416
}, this));
407417
}, this);
408418
if (this._nbContentLoading == 1) {
@@ -477,6 +487,7 @@ jQuery(function($, undefined) {
477487
this.elts.cont.after(elts);
478488
}
479489
this.elts.cont.css('overflow', 'auto');
490+
this._callFilters('afterReposition');
480491
},
481492

482493
// Unreposition elements with a class nmReposition
@@ -486,6 +497,7 @@ jQuery(function($, undefined) {
486497
var elts = this.elts.all.find('.nmReposition');
487498
if (elts.length)
488499
this.elts.cont.append(elts.removeAttr('style'));
500+
this._callFilters('afterUnreposition');
489501
}
490502
},
491503
_internal = {
@@ -563,10 +575,11 @@ jQuery(function($, undefined) {
563575
_init: function(nm) {
564576
nm.filters = [];
565577
$.each(_filters, function(f, obj) {
566-
if ($.isFunction(obj.is) && obj.is(nm)) {
578+
if (obj.is && $.isFunction(obj.is) && obj.is(nm)) {
567579
nm.filters.push(f);
568580
}
569581
});
582+
nm._callFilters('initFilters');
570583
nm._callFilters('init');
571584
nm.opener
572585
.unbind('nyroModal.nyroModal nmClose.nyroModal nmResize.nyroModal')

0 commit comments

Comments
 (0)