Allow usage of jQuery UI themes from the themeroller

azriprajwala - March 2, 2009 - 11:21
Project:jQuery UI
Version:6.x-1.x-dev
Component:User interface
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs work
Description

Hi,

The main purpose of jquery UI is its ability of using different themes for the widgets. At present the jquery ui module is not including any css. When I add any widget the respective theme has to be included automatically. If no theme is specified the base theme should be included. At present we need to include respective theme css files explicitly.

I changed drupal_add_js function to include the respective themes.

Please check the attached patch

Note: You need to apply http://drupal.org/files/issues/jquery_ui_external_compress_type_bug.patch patch for http://drupal.org/node/388356 bug.

After applying the patch you can download any customized theme that you created using the jqueryUI Theme Roller interface and use here. The theme will automatically load when you add the widget.

To use new themes use the following procedure

Download any theme from from the http://jqueryui.com/download link and extracted it. Copy theme directory to jquery_ui/jquery.ui/theme folder with the name of the theme. I downloaded Vader theme

>> unzip jquery-ui-personalized-1.6rc6.zip

>> cp -r theme /jquery.ui/themes/Vader

In my module I included that theme using the following function call

jquery_ui_add('ui.accordian','Vader')

That's it. The corresponding theme is enabled for that widget.

AttachmentSize
jquery_ui_including_css_feature.patch2.09 KB

#1

azriprajwala - March 2, 2009 - 11:25
Status:active» needs review

#2

Rob Loach - March 8, 2009 - 13:04
Version:6.x-1.2» 6.x-1.x-dev
Status:needs review» needs work

Nicely done, but I think it would be nice to have that $theme variable pulled in through a setting in the administration somewhere. Would be nice to add it only for widgets that need the CSS too ;-) .

#3

azriprajwala - March 9, 2009 - 05:40

Having administration setting page to specify theme is a good idea but this theme will apply to whole site. Now you can have different theme on different pages. All jquery ui widgets come with basic css. On single page keeping different css for different widgets is something which I need to check, because I am not sure if it is possible.

#4

azriprajwala - March 9, 2009 - 08:29

Having administration setting page to specify theme for specific page is good idea. I will work on this feature. Thanks Rob Loach for giving me feedback.

#5

azriprajwala - March 16, 2009 - 14:39

I implemented admin interface to set the default theme. Attach the patch and go to /admin/settings/jquery_ui page.
Here it will display the themes that are there in jquery_ui/jquery.ui/themes/ directory.
If you want to use default theme just add widgets with
jquery_ui_add('ui.accordian');
If you want to override default theme and want to use different theme then use
jquery_ui_add('ui.accordian','Vader');

Note: Please attach first patch before attaching this patch

AttachmentSize
jquery_including_css_admin_settings.patch 2.21 KB

#6

azriprajwala - March 16, 2009 - 14:39
Status:needs work» needs review

#7

psynaptic - April 27, 2009 - 15:01

Where does base in variable_get('jquery_ui_default_theme', 'base'); come from? I can't seem to locate it in any jQuery UI theme download package.

Edit: I downloaded jQuery UI 1.7.1: for jQuery 1.3+ and base was indeed included. This doesn't seem to be included in the jQuery UI 1.6: for jQuery 1.2.6 packages. As far as I can see jquery_ui currently works with jQuery UI 1.6: for jQuery 1.2.6 so there is no base theme.

Am I missing something or do we need to make this work without the base theme?

#8

psynaptic - April 27, 2009 - 17:35
Title:Automatic including of themes» Allow usage of jQuery UI themes from the themeroller

I've improved the patch and feel it is now ready to be committed.

I have removed the necessity to apply this patch in the original post:

http://drupal.org/files/issues/jquery_ui_external_compress_type_bug.patch

I kept the $theme variable passed into the function so the theme of each widget can be changed in the call to jquery_ui_add(). I also kept the admin page with settings form but cleaned up the way theme folders are discovered. The variable jquery_ui_theme is still used to set the theme on a site basis.

I have followed coding standards apart from the concatenation operator which follows the 7.x behaviour (this was already used in the file so I thought it would be best to conform to this).

There is still the problem that the 'base' theme is not present in the jQuery UI 1.6 theme packages downloaded from http://jqueryui.com/themeroller/ so I'd like to know if anyone has an idea of how we can deal with this. Maybe we should discover the themes and just enable the first found until another is set in the admin?

There is also extraneous whitespace on lines 17 and 57 but I didn't want to include that with my patch.

AttachmentSize
jquery_ui_themes-388384.patch 2.17 KB

#9

psynaptic - April 27, 2009 - 17:24

In keeping with the new release system and this post:

http://drupal.org/node/362509

I have changed the "base" theme in variable_get('jquery_ui_theme', 'base'); to "flora".

This is the default theme name when downloading the package from:

http://code.google.com/p/jquery-ui/downloads/list?q=1.5

AttachmentSize
jquery_ui_themes-388384_v2.patch 2.14 KB

#10

psynaptic - April 27, 2009 - 17:26

Whitespace cleanup only.

AttachmentSize
jquery_ui_themes-388384_v3.patch 2.18 KB

#11

psynaptic - April 27, 2009 - 18:05

The download from http://code.google.com/p/jquery-ui/downloads/list?q=1.5 contains a theme with files arranged as such:

  • flora.accordion.css
  • flora.all.css
  • flora.css
  • flora.datepicker.css
  • flora.dialog.css
  • flora.resizable.css
  • flora.slider.css
  • flora.tabs.css

Whereas the Theme Roller has this structure:

  • images
  • ui.all.css

How do think we should get around this? It seems the Theme Roller is only distributing packages with ui.all.css rather than individual files.

#12

psynaptic - April 27, 2009 - 20:20

My lord, just had a good look at the CSS output from the Theme Roller and it SUCKS!

I think all development must have moved to 1.7 and 1.6 will be all but abandoned. I'm going to make my own CSS for this as what is output from the Theme Roller is no good for this project.

This issue has just been pushed right to the back of my queue unless someone comes up with something I may have missed.

#13

azriprajwala - April 27, 2009 - 23:50

Thanks for improving my patch. When I am posting this feature. the http://jqueryui.com/themeroller/ is different. They changed the directory structure. It looks like my patch does not work with 1.6 version. I downloaded 1.6 version of jquery_ui custom theme. After extracting, in the css folder there is a custom-theme directory. We can keep this in jquery_ui/jquery.ui/themes directory but it is not having ui.core.css, ui.theme.css.

jquery 1.7 version directory structure is good. I think it is better to use jquery ui 1.7 version. To use jquery-1.3.2 version , we can suggest the users to use jquery_update development code.

Prajwala

#14

azriprajwala - April 27, 2009 - 23:58

I did not check http://code.google.com/p/jquery-ui/downloads/list?q=1.5 link.
Now also when I download jquery_ui development bundle from the jquery_ui home page http://jqueryui.com/home , I am getting the theme as base. You can download from http://jquery-ui.googlecode.com/files/jquery-ui-1.7.1.zip location.

#15

psynaptic - April 28, 2009 - 11:36

So are you saying that jquery_update dev version now supports jQuery 1.3.2?

I agree jQuery UI 1.7 is much better than 1.5.3.

Edit: Ok, jquery_update 6.x-2.x-dev works with jQuery 1.3.2 so I think we should rebuild this patch to work with only jQuery 1.7 rather than the IMO very poor 1.5.3.

#16

azriprajwala - April 28, 2009 - 12:24

yes I used jQuery 1.3.2 and jQuery UI 1.7 in one of my project. It is better to support new version than struggling to support older version. If we use use jQuery UI 1.7 , I hope my original patch is good, there might be small changes required.

#17

psynaptic - April 28, 2009 - 12:36

Current instructions to get Theme Roller themes working with the latest patch in this issue are:

  1. Install jquery_update 6.x-2.x-dev
  2. Install jquery_ui 6.x-1.x-dev
  3. Apply the patch from #10
  4. Download jQuery UI 1.7 from http://jquery-ui.googlecode.com/files/jquery-ui-1.7.1.zip
  5. Extract the jquery-ui-1.7.1.zip archive and place the resulting folder in the jquery_ui module folder and rename it to jquery.ui
  6. Download a theme from the Theme Roller and extract the archive
  7. Copy the css/custom-theme folder to jquery_ui/jquery.ui/themes/ (you can rename the custom-theme folder to anything you like and the resulting path should be in the form jquery_ui/jquery.ui/themes/custom-theme)
  8. Rename the file custom-theme/jquery-ui-1.7.1.custom to custom-theme/ui.all.css

You then need to select custom-theme as the theme for jquery_ui on admin/settings/jquery_ui

#18

azriprajwala - July 25, 2009 - 07:00

Install jquery ui module by following bellow steps.

  1. Install jquery_update 6.x-2.x-dev
  2. Install jquery_ui 6.x
  3. Apply the patch attached to #33 http://drupal.org/node/388384#comment-1851354
  4. Download jQuery UI 1.7 from http://jquery-ui.googlecode.com/files/jquery-ui-1.7.2.zip
  5. Extract the jquery-ui-1.7.2.zip archive and place the resulting folder in the jquery_ui module folder and rename it to jquery.ui
  6. Download a 1.7.2 version theme from the Theme Roller and extract the archive
  7. Copy the development-bundle/themes/[custom-theme-name] folder to jquery_ui/jquery.ui/themes/

You then need to select custom-theme as the theme for jquery_ui on admin/settings/jquery_ui

AttachmentSize
jquery_ui_388384_v4.patch 2.92 KB

#19

psynaptic - April 30, 2009 - 08:07

Thanks prajwala!

Any testers?

#20

azriprajwala - April 30, 2009 - 18:33

To make testers life easy. I attached a jQuery UI Test page module.

Just install and enable the module. Then you will see a jQuery UI Example link in the navigation. Click on the line then you should able to see Accordian, Tabs, Slider, DatePicker, Progressbar, Dialog, overlay and shadow, framework icons on the page.

This page is having all widgets supported by jQuery UI.

Try checking all widgets.

Try changing the JQuery UI theme from admin > settings > jquery ui page. The theme should effect on the example page.

AttachmentSize
jqui_test.zip 5.68 KB

#21

adrinux - May 1, 2009 - 13:00

Patch from http://drupal.org/node/388384#comment-1530114 applies, works as described. I successfully modified a theme using the theme builder, downloaded and installed it.

Nice work :)

#22

golchi - May 20, 2009 - 01:34
Status:needs review» reviewed & tested by the community

I check and used this patch. It works as described. Good job (for a newbie you may need the http://drupal.org/files/issues/jqui_test.zip file to see how to use both the module and patch).

#23

kardave - June 8, 2009 - 14:05

I can confirm the above comment. I did the steps in #18, and working correctly.

Thanks,
Dave

#24

sun - June 21, 2009 - 01:05
Status:reviewed & tested by the community» needs review

This patch slightly overlaps with #266692: Settings for the theme used by jQuery UI - can anyone clarify the difference(s)?

#25

KiamLaLuno - June 21, 2009 - 04:24
Status:needs review» needs work

The patch should also add the code to change the module priority in the installation file; differently, the module would include the CSS files before other modules have the chance to set a different theme.

As reported by sun in #266692: Settings for the theme used by jQuery UI, the value for the new priority should be the maximum value between 10, and the higher priority used by any enabled module.

#26

azriprajwala - June 22, 2009 - 08:06

With this patch we no need to define any .inc files and get_info functions.

This patch search for the different themes in the /jquery_ui/jquery.ui/themes folder. In the admin>settings>jquery_ui configuration page, It will display the different theme directories in the /jquery_ui/jquery.ui/themes folder. By default it will have 'base' theme.

This patch does not depend on the drupal theme that used. If the user want new theme for the jquery ui widgets, he can download theme from jQuery UI themeroller or can create new jquery UI theme and place in the jquery_ui/jquery.ui/themes folder.

I do not see any need to provide module priority. I used this patch in Accordion Blocks and Facebook Stream module. It works fine.

#27

KiamLaLuno - June 22, 2009 - 15:50

I thought the module implemented hook_init() to load the CSS files, but I was wrong. In that case, to change the module priority is not necessary at all.

#28

ck9 - June 23, 2009 - 06:51

Can someone please post idiot proof instructions on installing a new theme for a datepicker. I see a themes/default directory in my jquery.ui folder for v1.6. I'm assuming all this php / hook stuff is for module developers.

#29

KiamLaLuno - June 23, 2009 - 14:06

The topic of this report is how to change the code to make it possible to change the widget theme basing on the theme used from Drupal. It's not a report for the end user, but for the maintaners of the project.

If you think the instructions are not clear, you should open a new report; attaching a comment to the first report you find is the right way to not get any answer.

#30

ck9 - June 23, 2009 - 15:07

I suddenly get the impression I just walked in on an important meeting. I'll be leaving now. =)

#31

ultrus - July 8, 2009 - 15:33

Hello,
I'm totally new to using patches, but I gave it a shot. I think I'm going in the right direction, but some errors occurred. Here's what I did:

  1. Downloaded jQuery UI 6.x-1.3 from http://drupal.org/project/jquery_ui
  2. Ran into some issues once I installed Accordion Blocks from http://drupal.org/project/accordion_blocks, and was directed to this page to patch the CSS issue.
  3. Downloaded patch from http://drupal.org/files/issues/jquery_ui_388384_v4.patch
  4. Copied everything over to my Mac, moved patch to jquery_ui/jquery_ui_388384_v4.patch
  5. Ran: patch < jquery_ui_388384_v4.patch
  6. Finished with the results below.

command line output:

patching file jquery_ui.module
Hunk #1 succeeded at 34 (offset 9 lines).
Hunk #2 succeeded at 52 (offset 9 lines).
Hunk #3 succeeded at 62 with fuzz 2 (offset 9 lines).
Hunk #4 FAILED at 81.
Hunk #5 FAILED at 100.
2 out of 5 hunks FAILED -- saving rejects to file jquery_ui.module.rej

jquery_ui.module.rej:

***************
*** 75,80 ****
        }
        $js_path = $jquery_ui_path . '/' . $file_path;
        drupal_add_js($js_path);
        $loaded_files[$file] = $js_path; // or TRUE...
      }
    }
--- 81,88 ----
        }
        $js_path = $jquery_ui_path . '/' . $file_path;
        drupal_add_js($js_path);
+       $css_path = $theme_path . '/' . $file . '.css';
+       drupal_add_css($css_path);
        $loaded_files[$file] = $js_path; // or TRUE...
      }
    }
***************
*** 92,94 ****
 
    return $version;
  }
--- 100,135 ----
 
    return $version;
  }
+
+ /**
+  * Implementation of hook_menu()
+  */
+ function jquery_ui_menu() {
+   $items['admin/settings/jquery_ui'] = array(
+     'title' => 'jQuery UI',
+     'description' => 'Configure settings for jQuery UI module.',
+     'page callback' => 'drupal_get_form',
+     'page arguments' => array('jquery_ui_settings'),
+     'access arguments' => array('administer site configuration'),
+   );
+   return $items;
+ }
+
+ function jquery_ui_settings() {
+   $theme_path = JQUERY_UI_PATH . '/themes';
+   $files = file_scan_directory($theme_path, '.*', array('.', '..', 'CVS', '.DS_Store'), 0, FALSE, 'basename');
+
+   $options = array();
+   foreach ($files as $name => $file) {
+     $options[$name] = $name;
+   }
+
+   $form['jquery_ui_theme'] = array(
+     '#type' => 'radios',
+     '#title' => t('Choose jQuery UI theme'),
+     '#default_value' => variable_get('jquery_ui_theme', 'base'),
+     '#options' => $options,
+   );
+
+   return system_settings_form($form);
+ }

Any thoughts on how to fix this? Is there a patched file or files I can download and replace? That would make my life wonderful for this 'quick' project I'm working on. I appreciate the assistance as I build on my tiny but growing Drupal muscles. :)

#32

azriprajwala - July 9, 2009 - 04:56

Hello ultrus,

Thanks for mentioning patch error for the new version of jquery ui.

I created this patch using jquery_ui 6.x-1.2 version. Try downloading jquery_ui 6.x-1.2 from http://drupal.org/node/274037 and apply this patch for now.

I will create new patch file for the latest version of jquery_ui and upload here.

Regards,
Prajwala

#33

azriprajwala - July 25, 2009 - 06:51

Created new patch which support latest version of jquery_ui module. Please use the patch attached to this comment.

AttachmentSize
jquery_ui_388384_v5.patch 2.89 KB

#34

dirk negen - July 25, 2009 - 07:54

Hi there, I was wondering where exactly to apply the patch?

#35

azriprajwala - July 25, 2009 - 09:33

The above patch add some more code to jquery_ui.module file. check http://drupal.org/patch/apply to how to apply patch.

#36

bluestarstudios - August 15, 2009 - 12:55

will this become part of the next jQuery UI module release?

#37

azriprajwala - August 17, 2009 - 02:16

Looking for becoming part of jquery ui release.

#38

adrinux - August 25, 2009 - 16:15

@azriprajwala please learn how to create patches against a cvs checkout :) You really shouldn't need to specify the file when applying a patch.

Attached is a different version of the latest patch, which should apply as usual:
"patch -p0 < jquery_ui_388384_v5_clean.patch"

Confirmed as working when applied to jquery_ui.module 6.x-1.3.

AttachmentSize
jquery_ui_388384_v5_clean.patch 2.74 KB

#39

adrinux - August 25, 2009 - 16:21

Oh, and using jQueryUI 1.7.2 with, jquery_update 6.x-2.x-dev (2009-Apr-24) and jQuery 1.3.2.

#40

Tim Saltzman - September 3, 2009 - 09:22

Hi I have my drupal site hosted on godaddy. Can someone tell me where and how to install this patch please? I can't see where I am supposed to enter the commands for this patch. I need to install this patch to be able to use the Accordion Blocks Module.

#41

KiamLaLuno - September 3, 2009 - 10:04

@#40: The patch should simply applied to a local copy of the module files, which are then copied to the server through FTP (I think you don't have SSH access to the server where your site is hosted).
See Applying patches for more details.

#42

johnny_up - September 14, 2009 - 15:44
Category:feature request» support request

Hi,
I've tried to implement this, and I've had no luck at all. I downloaded/installed jquery update (jquery_update-6.x-1.1) , then jquery_ui (jquery_ui-6.x-1.3), and enabled them ok without any errors. I downloaded the new jquery_ui (jquery-ui-1.7.2), and added it, as well as the new theme from themeroller (jquery-ui-1.7.2.custom). Then came the patch...The patch - jquery_ui_388384_v5.patch - successfully ran (or so it seemed, I used CygWin), but the I now get the error:
Fatal error: Call to undefined function jquery_ui_add() in the accordian blocks module on line 13. Any ideas? I'll attach the resulting new module file after the patch as a txt in case it'll help.

My goal is to use the accordian blocks module...

Thanks in advance!

AttachmentSize
jquery_ui.module_patched.txt 3.94 KB

#43

azriprajwala - September 15, 2009 - 02:26

Hi johnny,

You should install jquery update 6.x-2.x-dev version because jquery ui 1.7 need jquery 1.3.2.

Fatal error: Call to undefined function jquery_ui_add() in the accordian blocks module on line 13. Any ideas? I'll attach the resulting new module file after the patch as a txt in case it'll help.

This error will come because if you do not enable jquery_ui module.

Please follow the instructions specified at http://drupal.org/node/388384#comment-1530114

You have to enable jquery_update, jquery_ui then accordion_blocks module.

#44

johnny_up - September 17, 2009 - 23:28

Thanks for that, azriprajwala - I seriously appreciate it. The problem was that I didn't install the right version of jQuery_update. It works like a charm now.

#45

GiorgosK - September 29, 2009 - 15:56
Category:support request» feature request

This is not a support request
please don't change category - unless you know what you are doing

tried latest patch v5, with jquery update 2.x installed and jquery ui 1.3
the css are inserted correctly

<link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/jquery_ui/jquery.ui/themes/ui-lightness/ui.core.css?A" />
<link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/jquery_ui/jquery.ui/themes/ui-lightness/ui.theme.css?A" />
<link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/jquery_ui/jquery.ui/themes/ui-lightness/ui.datepicker.css?A" />

but I can't get datepicker to style at all when using ui-lightness

any ideas

 
 

Drupal is a registered trademark of Dries Buytaert.