I stopped counting the issues that complain about weird effects of using drupal_add_library(), specifically regarding jQuery UI.
The problem is that we auto-load the default theme of jQuery UI, which is then applied to all elements using jQuery UI's CSS classes (mostly dynamically generated DOM elements).
Developers now circumvent this issue by not using drupal_add_library() and loading the wanted JavaScript files separately instead. Which entirely defeats the purpose of the library registry.
A quick but totally senseless fix would be to remove or comment out the stylesheet files in system_library() for jQuery UI.
I personally do not understand the jQuery UI theme API yet. However, looking at http://jqueryui.com/docs/Theming/API, I see many similarities to the CSS classes used in Drupal. Even kinda feels like re-inventing the wheel.
Further options:
- Can the CSS classes, jQuery UI uses, be globally defined/altered, so we could just tell to use our class names?
- Can we implement a default theme that implements those classes, but basically is an empty/reset template only, not applying any weird styles?
Comment | File | Size | Author |
---|---|---|---|
#19 | jqueryuialter.patch | 28.13 KB | RobLoach |
#19 | images.zip | 25.68 KB | RobLoach |
#19 | garlandui.png | 134.22 KB | RobLoach |
#5 | drupal.jquery-ui-theme.patch | 562 bytes | sun |
Comments
Comment #1
sunComment #2
mikehostetler CreditAttribution: mikehostetler commentedSubscribing and notifying the jQuery UI Team.
Comment #3
rdworth CreditAttribution: rdworth commentedThere are two main parts to a jQuery UI theme that are significant to this issue:
- functional/layout css
- presentational/look-and-feel css
We keep a clean separation between these two. All css required for plugins to function are in individual files:
ui.dialog.css
ui.tabs.css
etc.
All css for colors, borders, font sizes, font faces, background colors, images, etc are in a single file:
ui.theme.css
It would seem this is the one that's causing the most pain for users as it has a default style they either don't want, or want to override completely. If all they've asked for is to include jQuery UI, and you want enough css for the plugins to be functional with the js, you'll want these files:
ui.core.css
ui.accordion.css
ui.datepicker.css
ui.dialog.css
ui.progressbar.css
ui.resizable.css
ui.slider.css
ui.tabs.css
but not
ui.theme.css
Comment #4
rdworth CreditAttribution: rdworth commentedYou can get that list of files programatically from:
http://jquery-ui.googlecode.com/svn/tags/1.7.2/themes/base/ui.base.css
Notice the contents of ui.all.css:
@import "ui.base.css";
@import "ui.theme.css";
So you only want the base of the base theme.
Comment #5
sunThank you!
Since I don't have any clue about how we want to handle custom jQuery UI themes in Drupal (probably to be investigated in the contributed http://drupal.org/project/jquery_ui module), it seems like this is a one-line fix then. :)
Comment #6
Gábor Hojtsy@sun insits on #517688: Initial D7UX admin overlay that we need to use drupal_add_library() to add the JS for the jQuery UI we use (we don't need *any* of the CSS). Obviously we can add any of the CSS and then add as much again to override / clean it up. He says this issue would solve that, but it does not seem so yet. I'm not at all convinced that when we need to cherry-pick from library files, we should use drupal_add_library() anyway. Files added with drupal_add_js() and drupal_add_css() are equally alterable, even if they do not inherit altering of the parent library (which is as far as I understand @sun's main concern).
Comment #7
mattyoung CreditAttribution: mattyoung commented.
Comment #8
sunEither this issue gets fixed or we roll back hook_library(). The main reason for having a library registry was jQuery UI in core. Now we have one, but it cannot be used. Tagging as release blocker.
Comment #9
Damien Tournoud CreditAttribution: Damien Tournoud commentedI don't see any reason to remove the base "theme" (ui.theme.css). This stylesheet can be overridden by the (Drupal) theme if needed. What we need is a way to style differently a particular UI element (ie. the Overlay, which is not *every* dialog).
If I'm not mistaken, we simply have to use the "dialogClass" [1] option to add our own "drupal-overlay" class to the overlay dialog.
[1] http://docs.jquery.com/UI/Dialog#option-dialogClass
Comment #10
RobLoachDamien is right. The Overlay's CSS has to build ontop of the existing ui.theme.css rather then implementing its own. If any jQuery UI element is added to the page (an element requiring ui.theme.css), this element will in turn break the Overlay's CSS. To my knowledge the overlay has a .overlay class which we should apply to all the overlay-specific dialog changes. #256 demonstrates building off of
ui.theme.css
instead of implementing its own that will break other jQuery elements.So, due to this, I'm setting this issue to "by design". Thanks!
Comment #11
sunNo, please read the explanations above.
ui.theme.css is a theme. Clashing with Drupal themes.
ui.base.css (resp. the individual files) are base styles required for the functionality.
A way forward is to remove ui.theme.css (this patch) and let jquery_ui module in contrib figure out how to build a connection between Drupal themes and jQuery UI themes.
Comment #12
RobLoachhook_library_alter() was made to support switching the theme, possibly with administration through the Color module. The problem is that jQuery UI elements require a theme. If we have any other jQuery UI element added to the page along with a ui.theme.css, it will break the Overlay. We need to work with ui.theme.css, not against it.
Comment #13
sunMy understanding is that
- Without ui.theme.css, there is almost no theme besides the jQuery UI base styles. A Drupal theme or Drupal module has to cater for applying styles above UI's base styles in appropriate places. That is the default, and that is why we remove ui.theme.css.
- Whatever wants to provide a UI theme has to alter the registered libraries to inject custom UI theme stylesheets. Most likely, this is a Drupal theme.
- Modules should always work with the UI base styles only, so a Drupal theme is always able to apply a consistent UI theme, just like it provides a consistent Drupal module theme.
- No Drupal theme or module wants to load ui.theme.css, because that is a real theme that no one wants to apply to a site that is already using another theme. You also don't want to apply two different Drupal themes at the same time.
Comment #14
sun#87994-92: Quit clobbering people's work when they click the filter tips link is another issue that wants to leverage jQuery UI. That one makes it even more apparent that Drupal themes need to implement UI theme styles in case they want to support it.
Comment #15
Damien Tournoud CreditAttribution: Damien Tournoud commentedOf course, themes will register a
ui.theme.css
file, that will override the core providedui.theme.css
. I'm not sure I understand what is the problem.Comment #16
RobLoachjQuery UI's
ui.theme.css
is a CSS Framework with the basic styles to make jQuery UI elements usable. jQuery UI's Smoothness is the equivalent to Drupal's Stark. Stark has enough CSS make Drupal usable, the same goes for jQuery UI's ui.theme.css. Drupal requires a theme to make it usable, jQuery UI requires a ui.theme.css to make it usable.With #591794: Allow themes to alter forms and page, you'll be able to implement
[theme]_library_alter
and swap outui.theme.css
with your own theme's ui.theme.css. As I've demonstrated in the latest overlay patch we can work with ui.theme.css and still make the overlay look right because we can add our own class names to the elements. This means that the overlay won't break when other jQuery UI elements are active that require ui.theme.css.Yes jQuery UI elements work without a ui.theme.css, but they arn't usable. These elements expect those classes to be there.
Comment #17
RobLoachAfter some discussion, we have a plan of action:
An issue blocker for this #591794: Allow themes to alter forms and page.
Comment #18
sunTagging absolutely critical clean-ups for D7. Do not touch this tag. Please either help with this or one of the other patches having this tag.
Comment #19
RobLoachThis patch demonstrates swapping out ui.theme.css with a new ui.garland.css. Screenshot.
Steps Taken
The Key
Where To Now?
This shows that we are on the right track, and what we have had in mind is working. What we should focus on now are:
Comment #20
RobLoachChanging the title a bit to match what we want to do :-) .
Comment #21
sun@Rob Loach: Thanks for your work on this!
I agree that these are the most reasonable and the only feasible steps that can be done in the remaining time-frame. Although I'd rather like to see misc/ui/ui.theme.css being moved into a custom, stripped down modules/system/ui.theme.css, I can live with this until D8 (when we all will know better).
The first issue on your list is the most critical and also RTBC. The second should almost be ready...
Are the any actionable items for this issue? Or do we simply want to keep it as meta-issue?
The ui.theme.css files for Garland and Seven, we should probably move into separate issues each (and those can happily go in after API freeze).
Comment #22
RobLoachI created #606782: Give Garland a nice looking jQuery UI theme. We'll also need one for Seven so that the popup looks nice when embedded in the Overlay (screenshot).
Comment #23
rickvug CreditAttribution: rickvug commented.
Comment #24
RobLoachAnother actionable item: #614494: Give Seven a nice looking default jQuery UI theme.
Comment #25
JacineCan someone tell me (or point me to information on) where Drupal 7 is using jQuery UI or any of the styles provided by ui.theme.css? I read #315035: Add jQuery UI elements to core so I am aware of where it "can" be used, but I don't think any of it has actually been done and would like to confirm that.
For the record, this totally goes against the whole "Stark" movement. Smoothness is a full-on theme. It's not at all like Stark in every way that counts. Stark doesn't mess with your fonts, borders, border-radius, background colors, images, etc. Having to essentially create a whole jQuery UI theme on top of a Drupal theme is a burden IMO, but since this looks like it's here to stay it should definitely be stripped down.
2 questions:
Comment #26
JacineI started to work on a stripped down version of ui.theme.css. I could submit a patch for it, but I'm not sure what you guys are looking to do, if anything. If you're not willing to do anything with it for Drupal 7, please let me know. It could end up being documentation for themers. :)
Comment #27
jensimmons CreditAttribution: jensimmons commentedsub
Comment #28
markus_petrux CreditAttribution: markus_petrux commentedThanks a lot! This stuff is looking really great.
Once this is stable for D7, maybe it could be backported to jquery_ui module for D6.
Comment #29
scroogie CreditAttribution: scroogie commentedsubscribing
Comment #30
mcrittenden CreditAttribution: mcrittenden commentedSub.
Comment #31
RobLoachJacob found a great link on using multiple jQuery UI themes at once:
http://www.filamentgroup.com/lab/using_multiple_jquery_ui_themes_on_a_si...
What this shows us is that it's possible to swap jQuery UI themes out, build ontop of existing ones, and use multiple themes at the same time.
Comment #32
JacineIdeally there should be consistency between the classes that jQuery UI provides and the classes that Drupal provides for common widgets, like tabs, accordions, etc. To me, that means new theme functions for jQuery UI widgets and changes to existing theme functions where applicable.
It's too late for that, but ui.theme.css needs to be default with. Core CSS files are currently being littered with CSS that override overrides ui.theme.css instead of starting fresh with good code. See overlay-parent.css for an example:
Why? Because this is what the person writing the CSS has to start with:
And this is before we even get to the theme layer.
I believe that after Drupal 7 is released, and modules start using it, and writing CSS in the same manner, we are going to see a lot more of this type of messy code, and I think that sucks. While it is easy to say the file should be removed, certain widgets like the slider/dialog/overlay need minimal styling to be functional. I also think the icons are useful. I propose we do a stripped down ui.system.css file: http://bit.ly/4VuCxc (see the ui. stripped.css tab)
Does anyone have any feedback on this?
Comment #33
casey CreditAttribution: casey commentedSubscribing.
Comment #34
RobLoachThe CSS files don't look as scary in #679036: Upgrade to jQuery UI 1.8. It's easy to swap out the jQuery UI theme with one from the ThemeRoller using hook_css_alter(). jQuery UI needs a theme for it to be usable. I'd consider this issue fixed.
Comment #35
casey CreditAttribution: casey commentedLet's continue on #606782: Give Garland a nice looking jQuery UI theme and #614494: Give Seven a nice looking default jQuery UI theme then. If one of those lands we can mark this one fixed.
Comment #36
sunOver in #697224: Replace $.viewsUI.tabs with $.ui.tabs, Views tries to remove its own version of jQuery UI tabs and rely on core's instead.
Problem: A bizarre amount of CSS overrides are required to revert what ui.theme.css is doing by default.
Comment #37
casey CreditAttribution: casey commentedSo what needs to be done here?
Comment #38
JacineWell, for one, we need to see if this upgrade changes anything, like Rob says in #34: #679036: Upgrade to jQuery UI 1.8.
If not, giving each theme defaults is not the answer here. It's nice to do, but it's just a band-aid for those themes, and the problems with modules and custom theme having bad default CSS to start with would remain.
Comment #39
RobLoach#575298: Provide non-PHP way to reliably override CSS would help too :-) .
Comment #40
catchThis is nice to have, not a critical bug.
Comment #41
JoshOrndorff CreditAttribution: JoshOrndorff commentedI was looking at this queue (all open 7.x issues tagged with "release blocker").
Do we still want that tag on this issue?
Comment #42
nod_Comment #43
RobLoachThis is already possible with hook_library_info_alter() and hook_library_alter(). Seven got a nice looking jQuery UI theme in #614494: Give Seven a nice looking default jQuery UI theme. Any reason why this issue is still open?
Comment #44
RobLoachComment #45
sunI think the original issue is still not resolved — which somehow got side-tracked by the swappable themes sub-topic.
@Jacine nicely explained it in #32 once more.
However, it is still not clear whether we're actually going to start to use jQuery UI in Drupal 8 — see #1666920: [meta] Where/when to use jQuery UI
Only in case we will, we need to revisit this issue. Essentially:
jQuery UI's default ui.theme.css is not as "Stark" (minimal) as our defaults are. It contains too much branding and too many styles. The only way to make it as basic as Stark is to develop a stripped-down version, as @Jacine prototyped some time ago. That is, in order to prevent modules and themes from having to override any default styling in jQuery UI's default.
Drupal modules need to be able to load, say the Autocomplete plugin, without automatically loading a shittonne of CSS that suddenly needs to be customized and overridden by themers/site builders. When modules are adding JS plugins, then they only want the behavior/effect, only using the absolute minimum required styles to make the visual interface work. In other words, loading and applying the jQuery UI Autocomplete plugin should actually yield a similar look & feel as our current autocomplete widget; i.e., close to zero styling. As visible in the screenshots in #675446: Use jQuery UI Autocomplete, that is absolutely not the case.
Our current CSS clean-up efforts for D8 are essentially following that: $module.base.css for any required functional styling, $module.theme.css for minimum interface styles. Everything else is left to the Drupal theme — which may want to override/replace $module.theme.css entirely, but there's usually almost no default styling in there anyway.
Comment #46
RobLoachjQuery UI requires a theme (jquery.ui.theme.css), just like how Drupal requires a theme (Stark). It can be swapped with hook_library_info_alter(). jquery.ui.theme.css is the base theme that's shipped with jQuery UI. If we have issues with how jQuery UI's base theme looks, then we should work with them to fix it upstream... I'm not sure what the issue here is.
Comment #47
YesCT CreditAttribution: YesCT commentedcorrecting the tag to the more common one.
Comment #48
nod_Need input from the CSS folks to know how bad it is to theme jQuery UI stuff. Since we have dialog and autocomplete in core the answer should be easy to get.
Comment #55
apadernoComment #57
anruetherJust stumbling upon this issue without any activity in the last years. Closing as outdated, see related issue.