Hi,

I tried by specifying compression type for jquery_ui_add function as specified in the README.txt file.
But it is always using minified format. Actually this optional parameter support is not exist in the code. Please check the attached patch to fix this bug.

cheers,
Prajwala

Comments

pflame’s picture

Status: Active » Needs review
SamPolenta’s picture

Bug verified. I would add that this part of the readme file:

5. If desired, configure the module at Administer >> Site configuration >>
jQuery UI. Here you may select which level of compression the jQuery library
should use. It defaults to 'minified' compression, which strips comments and
white space.

also doesn't work. There is simply no code in the module for this.

pflame’s picture

Yes you are correct. The correct path is Administer >> Site Configuration >> Jquery Update. There is a mistake in the readme file

psynaptic’s picture

Using the jQuery Update settings page at Administer >> Site Configuration >> jQuery Update (?q=admin/settings/jquery_update) does change the file included via jquery_ui_add(). I have tested it and it works fine.

I don't see anything about specifying the compression type in README.txt for jquery_ui. I think just having the global setting under jquery_update is enough. Is there any reason I have missed that we might want to add the compression via the function call?

Edit: Ahh.. I see it now... It was removed from the dev version. Here are the diffs showing that is the case:

The top paragraph still seems valid:

5. If desired, configure the module at Administer >> Site configuration >>
jQuery UI. Here you may select which level of compression the jQuery library
should use. It defaults to 'minified' compression, which strips comments and
white space.

Should this be added back (obviously with the path change mentioned in #3)?

pflame’s picture

I feel it is better to add. Is the patch about explicitly specifying compression type is tested?

psynaptic’s picture

@prajwala: Do you intend to use different compression levels for different jQuery UI files? I would think having a setting in the admin is enough to turn minification on or off depending on if you're developing the site or not. This would be enough for me and I'm guessing others but if you have a use case that might help.

If you want to get this patch committed you will need to follow Drupal's coding standards.

pflame’s picture

StatusFileSize
new1.49 KB

It will be useful while developing, because I don't want to use any compression while I am developing, I can able to debug easily. So I prefer using no compression while development. of course I can able to change it using jquery_update admin settings page, but that will effect all pages. This is written in the README.txt file. I am using 6.x-1.2 version of jquery_ui.

If you wish to override the compression type selected in the settings
screen, you may do so by passing in an optional $type parameter. Possible
values are 'none', 'minified', and 'packed'.

jquery_ui_add(array('ui.draggable', 'ui.droppable', 'ui.sortable'), 'none')

This point is specified in README.txt but not implemented it.

I added new patch by following drupal coding standards.

Thanks,
Prajwala

sun’s picture

Title: Override compression type by passing optional $type parameter is not working » Allow to override compression type by passing optional $type parameter?
Category: bug » task
Status: Needs review » Needs work

I'm not sure this makes sense in any way.

Anyway, I'll reconsider later.

+function jquery_ui_add($files = array(), $compression_type = False) {

Constants are all uppercase in Drupal.

+  $compression = $compression_type ? $compression_type : variable_get('jquery_update_compression_type', 'mini');

Please wrap this (entire) ternary operator condition in braces, clarifying where the condition starts and ends, i.e. after the equal sign and before the semicolon.

avpaderno’s picture

I thought that the ternary operator has precedence over the assignment operator; if that is the case, the parenthesis are not necessary (or sun is talking of something else, and I have not understood what he meant).

avpaderno’s picture

I don't think that allowing any third-party modules to decide the type of compression is something that makes sense; it should be the administrator users to decide the used compression, basing on the files they copied.

sun’s picture

Status: Needs work » Closed (won't fix)

I agree, this does not make sense. You can override the compression type via the administrative settings or by overriding the variable via settings.php on your development/staging site.

Also, README.txt no longer states that one is able to do this anyway - which means this option was removed as part of another issue (probably bug report).

pflame’s picture

Status: Closed (won't fix) » Closed (fixed)

If you wish to override the compression type selected in the settings
screen, you may do so by passing in an optional $type parameter. Possible
values are 'none', 'minified', and 'packed'.

jquery_ui_add(array('ui.draggable', 'ui.droppable', 'ui.sortable'), 'none')

The above message is there in the README.txt 1.3 version. Now it is changed. So this patch may not be useful now. We can change these settings through jquery_update configuration page, so no need to create another configuration for the jquery_ui to change the level of jquery compression.

avpaderno’s picture

Status: Closed (fixed) » Closed (won't fix)
slybud’s picture

Just in case someone wonders :
variable_get('jquery_update_compression_type', 'mini');

=> for the jquery_update module version I am using (2.0-alpha1), this variable will never take the 'mini' value, only 'min'

So testing the value 'mini' for the variable $compression may be useless