Closed (fixed)
Project:
Chaos Tool Suite (ctools)
Version:
6.x-1.8
Component:
Miscellaneous
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
2 Aug 2010 at 22:57 UTC
Updated:
18 Apr 2013 at 16:52 UTC
Jump to comment: Most recent file
Comments
Comment #1
merlinofchaos commentedOk, here's an initial patch to make the modal a little more customizable.
You need to do two things to customize how the modal appears.
First, you need to create a settings array. You can do this most easily with a bit of PHP:
Then, when adding the 'ctools-use-modal' class to your link or button, *also* add the following class: 'ctools-modal-my-modal-style'. Note that 'my-modal-style' matches. You can use anything you want there.
modalSize can be 'fixed' or 'scale'. If fixed it will be a raw pixel value; if 'scale' it will be a percentage of the screen.
You can set:
Comment #2
Michsk commented// Removed this reply because it was badly implemented by me therefor the error showed.
// New reply:
I need to add some additional pixels to the calculated width and height of
$('div.ctools-modal-content', context).css. So i define the new settings.Now the width and height are set to fluid with .7 and .6. But now i need to add the pixels.
modal.js
So when the width and height are calculated i additionally need to add some pixels, because i'm using a table that has some images as 'borders'. When the extra pixels are not added the borders are hidden.
I hope my question is clear... Anyway the patch works, so i don't know if i may change this but i will set it to reviewd.
Comment #3
Michsk commentedComment #4
Michsk commentedAgain i am unable the create patches, so here is the new javascript file. This lets us define a addWidth and addHeight. So now we can add extra width and height on div.ctools-modal-content, good for themeing. Using:
merlinofchaos: i don't know if you want to keep the variable names the way they are or if you even want to go with this option, any input?
Comment #5
merlinofchaos commentedUnfortunately I can't review a javascript file. The way to make patches is to be sure to check out from cvs and make your changes to that. Then use cvs diff -up > issuenumber-patch-description.patch
It takes a bit the first time you do it, but once you're set up patching becomes very easy.
Comment #6
Michsk commentedok i guess there always has to be a first time. I will try to create a patch trough cvs.
Comment #7
Michsk commentedwell it is a patch tough it just doesn't seem good. It first delets everything and then adds it...
Comment #8
merlinofchaos commentedIt might have to do with unix linefeeds versus windows line feeds.
Comment #9
Michsk commentedsounds like that could be the case since i'm on a windows machine.
Comment #10
Michsk commentedno idea on how to convert this to unix. I read http://drupal.org/node/324 which states
cvs diff [options] file_to_diff | unix2dos -u > file_to_diff.patchSo after trying
diff -up js/modal.js js/@modal.js | unix2dos -U > modal-customizable-altered.patchi got a error, read the unix2dos --help and it stated i cant use -U with unix2dos. So tried
diff -up js/modal.js js/@modal.js | dos2unix -U > modal-customizable-altered.patchEverything i tried return the same patch as i uploaded here.
Comment #11
Michsk commentedOk got this working by basically opening the original file (unix linebreaks), saving it. And the creating the patch. So here's the patch.
Comment #12
Michsk commentedMerlin: got some time to take a look at this, and if so, what do you think of it. Does it need a explanation for why this would be needed?
Comment #13
merlinofchaos commentedI have glanced at it. What you want to do makes sense. I would probably do it a slightly different way. When I get back to this I'll create an updated patch.
Comment #14
Michsk commentedok great.
Comment #15
tizzo commentedlasac's patch needed to be rerolled to apply directly to head (use cvs diff -up > patchname.patch) to patch against head, not diff with the patched version of a module.
I applied those changes and also reworked the height calculation from
'height': (height - 35) + 'px'to'height': (height - 45) + 'px'because 45 was reliably creating a size that would overlap the wrapper. I haven't tested that part enough to ensure that's not partly related to our theming...Comment #16
Michsk commentedtizzo: thanks i tried to create it against head but that command line didn't work for me. i keep getting the error that my root is not set.
This is how i try to set it:
i try to set it with anonymous but just can't get it to work. I don't really get why the height should be 10 px less but ill check it out. Again thanks for re-creating this.
Comment #17
merlinofchaos commentedLet's take the hardcoded x-add pixels and y-add pixels (that are 25 and 35 in the current) and move them to settings so that they can be adjusted.
Comment #18
Michsk commented@17: i totally agree.
Comment #19
Michsk commentedSome issues that have to do with these options:
Comment #20
merlinofchaos commentedNew patch. Should fix the throbber theming on modal loading, but I don't have an easy way to test it.
I don't have a good way to reproduce that this[0] is undefined problem either. I'm not getting it with the standard modal, so I'm not quite sure what's wrong.
Comment #21
merlinofchaos commentedI'm pretty close to going ahead and committing this one. Though. I guess it needs some proper documentation.
Comment #22
Michsk commentedI can write a documentation, tough i haven't done that before. Could we wait for one more day so that i can try to find out what that this[0] is undefined problem is?
Comment #23
merlinofchaos commentedNew patch.
This one gets rid of dimensions.js to get rid of that this[0] error. Also unhardcodes some calls to the original ctools modal setting and instead uses whatever is set to 'current' since there can only be one modal operating at at ime.
Comment #24
merlinofchaos commentedOne more reroll -- this one tries to fix broken usage of $.extend
Comment #25
merlinofchaos commentedThat last patch had some brokenness with $.extend. Hopefully this one is better.
Comment #26
merlinofchaos commented...and again...
Comment #27
Michsk commentedeverything works.
Comment #28
merlinofchaos commentedI went ahead and committed this.
Comment #29
Michsk commentedGreat, when will actually the next stable release be?
Comment #30
mahnster commentedHey lasac and merlinofchaos, thanks for doing this. I think this is what I'm looking for for making a modal's width and height more customizable. Yet I am not exactly sure how your latest patch is suppose to be used. Is one still suppose to follow the instructions for writing PHP to add a JS call to Drupal? What I am trying to do is, using the SimpleNews module's form for subscribing anonymous users for a newsletter, I want the subscription form to popup in a modal. So in my own module's code I load "simplenews_block_form_1" form ("1" is the Taxonomy of the Newsletter to subscribe to) by calling ctools. This works, but alas the modal is huge for the 3 fields I want to pop up. So, using this as a scenario, what would I need to do with ctools and making a customized JS file? Here is what my module does to call ctools:
Any thoughts what I can do to customize this? Appreciate the help.
Comment #31
mahnster commentedThe reason this is confusing is that in the first few comments, the first druapl_add_js() has "my-module-style" and then the next time that doesn't exist, but there is "face-style"....yet in the first post it said to set the link's class as "ctools-modal-my-modal-style". While you said that the class and JS name just have to match, yours doesn't match your original description of how to use what you are doing. So should I *ONLY* use the final drupal_add_js() code in this thread, or is that a build up of the original?
Comment #32
mahnster commentedOk, just to be complete, here is my callback function that generates the pages which contains the link to popup the subscripton box. Am I do this right? (I am using the latest dev version of ctools....assumed that was patched with all this):
This is using the drupal_add_js() from above with the name "face-style" as you see I set as the class when calling ctools_modal_text_button().
Am I doing this right? I see no change in the modal window's width and height. Arghh!!
Comment #33
Michsk commentedPlease wait for the documentation. Merlin will bring one out ASAP.
In the meanwhile i can provide you with what i'm working with:
And
Comment #34
merlinofchaos commentedDocumentation is now committed in the advanced help.
Comment #36
kirankkaran commentedHi,
I am looking for a way to avoid throbber. Now every time I click on any links I get a throbber working, which breaks my layout in many pages. Is there a way to disable throbber?
Comment #37
Michsk commentedIm not sure but wouldnt it work with css?
Comment #38
merlinofchaos commentedzeoxe: Please don't hijack issues. YOu already opened an issue for this.
Comment #39
gkatsanos commentedI can't find the documentation about this.. could you point where it is? (UX!..)
Comment #40
merlinofchaos commentedThe best documentation is probably in the ctools ajax sample module.
Comment #41
gkatsanos commentedI am not developing a module using cTools, I'm attempting to theme core modals in a different way..
I inserted this bit in my template.php:
but I didn't get a ..ctools-foo-bar class in the modal popup .. Am I missing something?
ps: There's a mention of an "advanced help" documentation in your last message,
I guess it was for the 6.x branch?
Comment #42
merlinofchaos commentedOh you're right. It's actually very nicely documented in ctools/help/modal.html (-- topic 'Modal' at admin/advanced_help/ctools )
It's in the D7 branch as well.
Comment #43
merlinofchaos commentedBTW adding the settings is half the job; you have to set the class on your link that leads to the modal as well. Once you have both pieces, the two can work together to provide your custom modal.