Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
color.module
Priority:
Normal
Category:
Task
Assigned:
Issue tags:
Reporter:
Created:
3 Jun 2013 at 10:42 UTC
Updated:
29 Jul 2014 at 22:28 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
mcjim commentedComment #2
mcjim commentedThere was a comment in the code to use drupal_add_library, but I've just use #attached.
Comment #3
tstoecklerPlease let's follow the best practice and use drupal_add_library().
Implement hook_library_info() and add the JS and CSS there. I can give you more specific instructions, in case you need any help.
Comment #4
mcjim commentedSpecific instructions would be welcome: the CSS/JS being added seems specific to the theme settings form rather than a general library? I may be misunderstanding something.
Comment #5
mcjim commentedThis is an odd one for sure.
color_library_info() already adds preview.js. The code here is checking to see if there is a preview_js file in the theme and adding that instead of colour/preview.js…
The CSS added is from the theme, also, so neither of these really count as libraries.
So, while this solution might not be perfect, it does help get rid of another call to drupal_add_css/drupal_add_js for now (see #1839338: [meta] Remove drupal_set_*() drupal_add_*() in favour of #attached/response for out-of-band stuff)
Re-setting to needs review to let the test bot have a go, but feel free to change if there is a better approach.
Comment #6
tstoecklerAhh, you're totally right. That approach should totally be improved in 1000 different ways, but that's not for this issue, and as it stands using a library is not possible/sensible in this case.
Thanks for sticking with this and setting me straight!
Comment #7
catch#2: 2010636-remove-drupal_add_.patch queued for re-testing.
Comment #9
wim leersStraight reroll.
We can't test this because theme-specific settings are currently broken in D8. #2040037: The requested page "/admin/appearance/settings/bartik" could not be found after installation
Comment #10
wim leers#9 is broken. The CSS and JS no longer ends up on the page. I strongly suspect the root cause for this are the recent changes to the (pre)process layer being removed/working differently and hence
#attachedassets in that phase no longer working… but at the same time #2004286: Defer calls to drupal_get_* functions until printed inside a template by adding a RenderWrapper class has not yet been committed, so I'm not entirely sure. Needs debugging.NR because it *is* possible to test the patch, you just have to clear your caches after installing current D8 head freshly — see #2040037: The requested page "/admin/appearance/settings/bartik" could not be found after installation for details.
Comment #12
adammaloneTiny tiny rewrite to pass form by reference
Comment #13
wim leersWorks great — thanks!
Comment #14
alexpottCommitted 749587e and pushed to 8.x. Thanks!