I realize we're waay past the date for feature requests, but this (IMO) is a very simple feature that helps out in UX. This patch adds the capability to add regions clickable regions in the inline preview area, so that a user can directly click on regions to select the palette element to edit.

This is done by adding classes to elements in the preview.html which get scanned by color.js. Patch includes changes to the core preview.html.

Classnames are called hotspot-palette-XXX where XXX is the name of the palette element. You can add the classes to div, p, a or other elements. Event propagation is stopped so that when regions overlap, the "topmost" region is the "winner" (e.g. an anchor within a paragraph).

To test: apply patch, clear caches if necessary. Then go to the theme settings for Garland at admin/appearance/settings/garland. Click on the text and links in the preview, and the proper element will be selected.

For further testing, I'm also including a preview.html for Bartik. (Rename it to preview.html and place it in the color/ folder inside the bartik folder)

Comments

janusman’s picture

Title: Make clicks on preview select proper palette field » Make clicks on theme settings preview select palette fields to edit

Better title.

janusman’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, hotspots_for_color_module_preview.patch, failed testing.

jensimmons’s picture

Issue tags: +Bartik

tagging

janusman’s picture

Status: Needs work » Needs review
StatusFileSize
new2.15 KB

Hmm, bad format in patch, new patch.

Status: Needs review » Needs work

The last submitted patch, hotspots_for_color_module_preview.patch, failed testing.

janusman’s picture

Status: Needs work » Needs review
StatusFileSize
new2.2 KB

Must be brown paper bag day.

mcrittenden’s picture

Status: Needs review » Needs work

Good idea, would make a nice last-minute feature if it's accepted.

+      // Make clicks on HTML preview elements with classnames
+      // "hotspot-palette-[key]" select the palette input text field.

Can we get a more understandable comment? I'd have trouble figuring out what this means. Maybe:

"Make clicks on elements in the preview box select the input text field that controls that element." or something? I don't see a need to mention the classname here, but that might just be me.

janusman’s picture

Status: Needs work » Needs review
StatusFileSize
new2.18 KB

Agreed. New patch, which also fixes a class in preview.html from the previous patch.

tim.plunkett’s picture

Version: 7.x-dev » 8.x-dev
Issue tags: -Bartik

I don't think this is backportable, unfortunately. Moving to 8.x.

janusman’s picture

My gut reaction was "maybe color.module won't even be in D8" =)

tim.plunkett’s picture

Not if I have anything to do with it!

brianV’s picture

Re-rolled against latest HEAD

markhalliwell’s picture

markhalliwell’s picture

Status: Needs review » Needs work
Issue tags: +Novice, +Needs manual testing
+++ b/core/modules/color/color.js
@@ -235,6 +235,15 @@ Drupal.behaviors.color = {
+      $('#preview .hotspot-palette-' + this.key)
+      .click( function(event) {

I'd rather this be on one line if possible. Also remove the extra space between "( function".

+++ b/core/modules/color/color.js
@@ -235,6 +235,15 @@ Drupal.behaviors.color = {
+        event.stopPropagation();

Any reason we can't just "return false;" here?

Also, if we're going to do this. We should probably also get some CSS styling to outline the element when you hover over it and also change the cursor to a pointer to imply that it is clickable. Bumping this to normal since I actually think this would be a nice feature to have.

tim.plunkett’s picture

It should be either

$('#preview .hotspot-palette-' + this.key)
  .click(function (event) {

or

$('#preview .hotspot-palette-' + this.key).click(function (event) {

with the space after function, and if its split, indented 2 spaces.

We never return false; anymore, always explicitly use event.preventDefault(); and event.stopPropagation(); explicitly, because they are not always both needed.

markhalliwell’s picture

Fair enough.

falkendk’s picture

Status: Needs work » Needs review
StatusFileSize
new636 bytes
new2.06 KB

Rerolled with the fix suggested by @tim.plunkett in #16

markhalliwell’s picture

Status: Needs review » Needs work
+++ b/core/modules/color/color.js
@@ -235,6 +235,14 @@ Drupal.behaviors.color = {
+      $('#preview .hotspot-palette-' + this.key).click(function (event) {

Actually, per jQuery Coding Standards: Event Delegation this should probably be:

$('#preview').on('click', '.hotspot-palette-' + this.key, function (event) {
zaporylie’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new2.09 KB

I attach patch to fix #19
In the same time I think that support for bartik preview.html should be added to this patch.

sumeet.pareek’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new2.21 KB

The patch in #20 worked for me.

I am also attaching a patch that makes the Bartik theme's colored theme preview clickable too. But I would leave it to those more involved in this issue to take a call on if we should include support for Bartik and other theme's preview.html. I think we definitely should. Otherwise this nifty little UX addition would not be of much help.

If this goes in, the documentation for using colors module should also be updated.

sumeet.pareek’s picture

Issue tags: +SprintWeekend2015
alexpott’s picture

Version: 8.0.x-dev » 8.1.x-dev
Status: Reviewed & tested by the community » Postponed
Issue tags: +JavaScript

This issue introduces a new feature, so per https://www.drupal.org/core/beta-changes, we should postpone it to 8.1.x or later.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Project: Drupal core » Color backport
Version: 9.5.x-dev » 2.x-dev
Component: color.module » Code
Issue tags: -JavaScript +JavaScript

Color has been removed from core, #3270899: Remove Color module from core.

avpaderno’s picture

Status: Postponed » Active