Skip to content

Commit

Permalink
Update documentation in Readme file
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nyroDev committed Feb 25, 2011
1 parent efbabe9 commit 3fafa30
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ All function or callbacks receive the same nyroModal object as a unique paramete
The list of all function or callback that can be called in a filter:

* is: should return true or false to select the filter for the current or element or not. This function is **REQUIRED** !
* 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.
* init: called at the very beggining of the process. This function should bind element or create object needed later
* 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
* 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
Expand All @@ -214,6 +215,8 @@ Like the version 1, there is a bunch of others callback that you can define befo
* afterHideLoad: called just after the hideLoad animation
* beforeShowCont: called just before the showCont animation (also called in case of a transition, before beforeHideTrans)
* afterShowCont: called just after the showCont animation (also called in case of a transition, after afterHideTrans)
* afterReposition: called just after the .nmRepositon have been placed
* afterUnreposition: called just after the .nmRepositon have been replaced on theire initial positions
* beforeHideCont: called just before the hideCont animation
* afterHideCont: called just after the hideCont animation
* beforeShowTrans: called just before the showTrans animation (transition)
Expand Down
7 changes: 5 additions & 2 deletions js/jquery.nyroModal.filters.swf.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@
jQuery(function($, undefined) {
$.nmFilters({
swf: {
idCounter: 1,
is: function(nm) {
return nm._hasFilter('link') && nm.opener.is('[href$=.swf]');
return nm._hasFilter('link') && nm.opener.is('[href$=".swf"]');
},
init: function(nm) {
nm.loadFilter = 'swf';
},
load: function(nm) {
if (!nm.swfObjectId)
nm.swfObjectId = 'nyroModalSwf-'+(this.idCounter++);
var url = nm.store.link.url,
cont = '<div><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+nm.sizes.w+'" height="'+nm.sizes.h+'"><param name="movie" value="'+url+'"></param>',
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>',
tmp = '';
$.each(nm.swf, function(name, val) {
cont+= '<param name="'+name+'" value="'+val+'"></param>';
Expand Down
25 changes: 19 additions & 6 deletions js/jquery.nyroModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jQuery(function($, undefined) {

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

swfObjectId: undefined, // Object id for swf object
swf: { // Default SWF attributes
allowFullScreen: 'true',
allowscriptaccess: 'always',
Expand Down Expand Up @@ -93,6 +94,8 @@ jQuery(function($, undefined) {
},
// Open the modal
open: function() {
if (this._nmOpener)
this._nmOpener._close();
this.getInternal()._pushStack(this.opener);
this._opened = false;
this._bgReady = false;
Expand All @@ -104,7 +107,6 @@ jQuery(function($, undefined) {
this._bgReady = true;
if (this._nmOpener) {
// fake closing of the opener nyroModal
this._nmOpener._close();
this._nmOpener._bgReady = false;
this._nmOpener._loading = false;
this._nmOpener._animated = false;
Expand All @@ -120,9 +122,17 @@ jQuery(function($, undefined) {

// Resize the modal according to sizes.initW and sizes.initH
// Will call size function
resize: function() {
this.sizes.w = this.sizes.initW;
this.sizes.h = this.sizes.initH;
// @param recalc boolean: Indicate if the size should be recalaculated (useful when content has changed)
resize: function(recalc) {
if (recalc) {
this.elts.hidden.append(this.elts.cont.children().first().clone());
this.sizes.initW = this.sizes.w = this.elts.hidden.width();
this.sizes.initH = this.sizes.h = this.elts.hidden.height();
this.elts.hidden.empty();
} else {
this.sizes.w = this.sizes.initW;
this.sizes.h = this.sizes.initH;
}
this._unreposition();
this.size();
this._callAnim('resize', $.proxy(function() {
Expand Down Expand Up @@ -400,9 +410,9 @@ jQuery(function($, undefined) {
this._callFilters('beforeShowCont');
this._callAnim('hideTrans', $.proxy(function() {
this._transition = false;
this._callFilters('afterShowCont');
this.elts.cont.append(this._scriptsShown);
this._reposition();
this._callFilters('afterShowCont');
}, this));
}, this);
if (this._nbContentLoading == 1) {
Expand Down Expand Up @@ -477,6 +487,7 @@ jQuery(function($, undefined) {
this.elts.cont.after(elts);
}
this.elts.cont.css('overflow', 'auto');
this._callFilters('afterReposition');
},

// Unreposition elements with a class nmReposition
Expand All @@ -486,6 +497,7 @@ jQuery(function($, undefined) {
var elts = this.elts.all.find('.nmReposition');
if (elts.length)
this.elts.cont.append(elts.removeAttr('style'));
this._callFilters('afterUnreposition');
}
},
_internal = {
Expand Down Expand Up @@ -563,10 +575,11 @@ jQuery(function($, undefined) {
_init: function(nm) {
nm.filters = [];
$.each(_filters, function(f, obj) {
if ($.isFunction(obj.is) && obj.is(nm)) {
if (obj.is && $.isFunction(obj.is) && obj.is(nm)) {
nm.filters.push(f);
}
});
nm._callFilters('initFilters');
nm._callFilters('init');
nm.opener
.unbind('nyroModal.nyroModal nmClose.nyroModal nmResize.nyroModal')
Expand Down

0 comments on commit 3fafa30

Please sign in to comment.