Closed (fixed)
Project:
Modal Frame API
Version:
6.x-1.x-dev
Component:
User interface
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
28 Sep 2009 at 22:05 UTC
Updated:
10 Jan 2010 at 15:20 UTC
Firstly, thanks for the excellent module, it really is excellent.
I'm having a minor issue with the create and reference feature.
The reference field has two content types to select from.
The modal dialog resizes correctly to select the content type to create.
However, the following node add form stays in the same small modal box and needs scrolling.
Is there a way to apply a resize to the modal dialog so it fits the node/add form?
thanks again,
DT
Comments
Comment #1
markus_petrux commentedhmm... the dialog should automatically resize itself when the new page is loaded. This is a feature of the Modal Frame API (the autoFit option). If it does not work like that, then the issue could be related to a bug in that module. Though, let's keep this issue in this queue for the moment.
If it does not resize, it could be caused by some javascript error in the node create form, or maybe a browser issue, though this feature should work on all major browsers.
Do you see any error? Have you tried with several browsers?
Comment #2
davidwhthomas commentedHi, thanks for the reply.
I didn't see any evidence of javascript errors in firebug, the browser is FF3. There's no javascript errors when viewing the node create form.
It seems it autoFits on the first modal popup (select the content type) but then the node add page does resize / increase after clicking.
The only thing different about the node forms is I'm using vertical_tabs and cck_fieldgroup_tabs but those all appear to work fine in the small modal window after scrolling.
I had a look around the code (I'm a developer) but couldn't see any obvious solution so I simply disabled the autoFit/resize option to keep the modal window filling the viewport. Perhaps that could be a config setting.
It would be good if it could be fixed though, so something to keep in mind. Perhaps the resize function could be manually called when the node add page is displayed.
Thanks for the excellent modules by the way, really well written and very useful - great work! :-)
cheers,
DT
Comment #3
davidwhthomas commentedComment #4
markus_petrux commentedI'm tempted to disable the autoFit option because the dialog will fit the whole viewport almost always. But first I would like to see what is causing this "malfunction" in your case, as it may be encapsulating another error, somewhere.
Let's try another procedure that should trigger this autoFit behavior when the node form is not involved, and that may help isolate the problem.
If you have enabled "Search and reference" and "Create and reference" options for this field, you should be able to see those options as tabs in the modal dialog. Well, if we open the dialog from the "Create and reference" button, with the autoFit option enabled, then size of the dialog decreases. Ok. So, what happens if you now click the "Search and reference" tab? If the contents of the search and reference view is bigger, then the autoFit option should act here as well and increase the size of the dialog.
The autoFit option is a feature of the Modal Frame API, and it should work even after a new page is loaded within the dialog. This happens when the child.js script of the Modal Frame API invokes the bindChild method of the parent window. If this behavior of the Modal Frame API does not work for you, then there's something wrong somewhere. We may want to find the cause of that.
If you tried this in Firefox, could there be an issue with a FF plugin? Have you tried with several browsers?
I tested with Firefox 3 and 3.5, IE 6 and 8, Opera 9 and 10.
Comment #5
markus_petrux commentedTo quote myself: "I'm tempted to disable the autoFit option..."
I think I'm going to do this.
Comment #6
davidwhthomas commentedThanks markus, sorry about the delay replying - my wife and I have just had a new baby!
Anyway, thanks again for the great module, node relationships is just awesome.
Re: that modal size issue, I'd suggest perhaps making autofit a config option with a setting to enable/disable?. As you probably know, drupal_add_js could be used to make the setting available from php to javascript, via the 'type' = 'setting' parameter.
That would allow the best of both worlds, however given the full viewport window is probably sufficient for most purposes, disabling autofit altogether is a reasonable solution.
best regards,
David
Comment #7
markus_petrux commentedOh, congratulations! That's a great thing. We have a couple of 6yo twins. :-) :-)
In regards to autoFit... I tried to disable this option altogether, but the modal frame is still resized when the main window resizes, and that's a bug in Modal Frame API I need to track. ie. the autoResize option enabled also triggers autoFit when the main window is resized. Solving this is not trivial. I'll have to find time to think about a solution for that in Modal Frame API...
Comment #8
davidwhthomas commentedThanks markus,
Just in case anyone else wants a quick fix for this one,
using this in noderelationships/js/node_form.js works for me ( lines 162-170 )
p.s fantastic module :-)
Comment #9
markus_petrux commentedI have just applied a few changes to Modal Frame API. The autoResize option is now gone in favor of just an autoFit option. Still, it works the same though.
Then, I think we need to fix this issue under the context of the Modal Frame API. I will propose a patch soon...
BTW, I'm updating the issue title.
AFAICT, there are 2 different things here:
1) One thing I do not completely get is why the modal frame is not resized when the child document is fully reloaded. I cannot really reproduce this. Note that the client side code in the child document (child.js) will invoke the bindChild() method on the parent, and there we're going to evaluate if the modal frame needs to be resized. If this does not work, then I think I need a step by step procedure to reproduce this particular case. It could depend on modules installed, or maybe on the browser...
2) What I can see is the modal frame not resized when the child document is updated using AJAX. This is because I'm not checking this kind of changes. We can deal with this case in different ways. I'll post a follow up on this soon...
Comment #10
markus_petrux commentedOk, so I have implemented a new method to capture changes on the size of the child document. It works like this:
1) When the main Drupal behavior is executed the first time, the current size of the document is saved.
2) When the main Drupal behavior is executed again, when something on the page triggers a new execution of Drupal.attachBehaviors(), for example after any AJAX event has changed the DOM, the size of the child window is computed, and if it has changed more than a few pixels, an event on the parent window is triggered to re-compute the size of the Modal Frame.
In addition to this, I have also implemented a new method to communicate events between child and parent windows. If works using custom event handlers installed on the parent window. This method allows us to keep the correct DOM context for jQuery manipulations.
http://drupal.org/cvs?commit=306888
I'm marking this issue as fixed because it all seems to work like a charm here. Please, feel free to re-open if this needs more attention. If that happens, please provide as much information as possible to reproduce the issue. Thanks