Problem/Motivation

A developer is unable to use custom markup for the throbber element (e.g. when integrating existing solution that already has styles and JavaScript code).

Proposed resolution

Move HTML code for the element to Drupal.theme function and use Drupal theming mechanism for JavaScript code.

CommentFileSizeAuthor
#59 480.gif6.22 KBheddn
#57 full-throbber-ux-test.gif787.36 KBAnonymous (not verified)
#57 production-version.patch1.27 KBAnonymous (not verified)
#49 interdiff-44-49.txt637 bytesAnonymous (not verified)
#49 2407859-49.patch13.17 KBAnonymous (not verified)
#44 2407859-44.patch13.17 KBAnonymous (not verified)
#44 2407859-44-test-only.patch7.62 KBAnonymous (not verified)
#40 2407859-40.patch13.17 KBAnonymous (not verified)
#40 2407859-40-test-only.patch7.63 KBAnonymous (not verified)
#32 interdiff.txt2.12 KBlauriii
#32 2407859-32.patch5.54 KBlauriii
#30 interdiff.txt4.08 KBlauriii
#30 2407859-30.patch5.62 KBlauriii
#29 2407859-29.patch4.15 KBGrandmaGlassesRopeMan
#29 interdiff-2407859-23-29.txt2.51 KBGrandmaGlassesRopeMan
#26 Screenshot from 2018-04-26 16-55-14.png63.7 KBamietpatial
#25 interdiff.txt3.87 KBlauriii
#25 drupal-themeable-throbber-2407859-23.patch4.01 KBlauriii
#23 drupal-themeable-throbber-2407859-23.patch4.01 KBfinnsky
#20 drupal-themable-throbber-2407859-20.patch6.73 KBvprocessor
#19 drupal-themable-throbber-2407859-19.patch6.91 KBvprocessor
#10 drupal-themable-throbber-2407859-10.patch6.55 KBsidharthap
#3 drupal-themable-throbber-2407859-3.patch4.31 KBjwilson3
#1 drupal-theme-throbber-element-2407859-1.patch1006 bytesaprogs
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

aprogs’s picture

Attached the patch.

jwilson3’s picture

Version: 7.x-dev » 8.0.x-dev
Issue tags: +TX (Themer Experience), +FX (Front End Experience), +JavaScript, +Ajax, +CSS

This feels like a super good idea and would bring the ajax throbber code inline with how the progress bar is built which also uses Drupal.theme js functionality.

This needed a re-roll because ajax.js has moved inside core/ folder and the functionality has slightly changed.

This patch also adds the new SMACSS compatibility to the throbber, and improves themability of the "fullscreen" progress indicator, as well as the "message" text that optionally accompanies the throbber in some cases.

jwilson3’s picture

Ugh, forgot the patch.

Status: Needs review » Needs work

The last submitted patch, 3: drupal-themable-throbber-2407859-3.patch, failed testing.

jwilson3’s picture

Test fail seems to be due to unrelated issues around missing schemas. Not sure... maybe try to rerun tests again later.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 3: drupal-themable-throbber-2407859-3.patch, failed testing.

jwilson3’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 3: drupal-themable-throbber-2407859-3.patch, failed testing.

sidharthap’s picture

Status: Needs work » Needs review
FileSize
6.55 KB

A new patch against updated 8.0.x branch. It seems dialog.css is placed inside the theme (classy, seven, stable) and this patch changed all these css files for throbber element.

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

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should 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.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should 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.

lauriii’s picture

Status: Needs review » Needs work

Very nice improvement!

+++ b/core/modules/system/css/components/ajax-progress.module.css
--- a/core/themes/classy/css/components/dialog.css
+++ b/core/themes/classy/css/components/dialog.css

+++ b/core/themes/seven/css/components/dialog.css
--- a/core/themes/stable/css/system/components/ajax-progress.module.css
+++ b/core/themes/stable/css/system/components/ajax-progress.module.css

I'm afraid that we are not allowed to make CSS or markup changes for stable or classy and we should keep these changes only for core, Seven and Bartik. What we could do is override the theme functions in Stable and then override them again in Seven and Bartik.

sidharthap’s picture

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

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.

vprocessor’s picture

Assigned: Unassigned » vprocessor
vprocessor’s picture

Assigned: vprocessor » Unassigned
Status: Needs work » Needs review
FileSize
6.91 KB

reroll

vprocessor’s picture

andypost’s picture

Status: Needs review » Reviewed & tested by the community

RTBC patch 19

star-szr’s picture

Status: Reviewed & tested by the community » Needs work

To @lauriii's point in #13, we shouldn't be changing markup. While I love the changes to make the markup more SMACSS-y (such as ajax-progress-fullscreen to ajax-progress--fullscreen), they will break sites so we can't allow them.

finnsky’s picture

Hi all!
Modified last patch without css changes. So out of box all will be same. Plus themeable throbbers.

andypost’s picture

Status: Needs work » Needs review
lauriii’s picture

Some minor changes for the latest patch. Also removed on instance where throbber was being created manually in the Field UI.

amietpatial’s picture

@Laurii I have reviewed your patch and it's working fine for me my site doesn't break

amietpatial’s picture

GrandmaGlassesRopeMan’s picture

Status: Needs review » Needs work
  1. +++ b/core/misc/ajax.es6.js
    @@ -811,6 +811,39 @@
    +   * @return
    

    Needs a return type, {string} I think?

  2. +++ b/core/misc/ajax.es6.js
    @@ -811,6 +811,39 @@
    +  Drupal.theme.ajaxProgressThrobber = function(message) {
    

    This should be a named function or preferably an arrow function.

  3. +++ b/core/misc/ajax.es6.js
    @@ -811,6 +811,39 @@
    +    return '<div class="ajax-progress ajax-progress-throbber"><div class="throbber">&nbsp;</div>' +
    +    Drupal.theme('ajaxProgressMessage', message) + '</div>';
    

    Template string.

  4. +++ b/core/misc/ajax.es6.js
    @@ -811,6 +811,39 @@
    +  Drupal.theme.ajaxProgressIndicatorFullscreen = function() {
    

    Same comment here about function/arrow.

  5. +++ b/core/misc/ajax.es6.js
    @@ -811,6 +811,39 @@
    +  Drupal.theme.ajaxProgressMessage = function(message) {
    

    Same comment here about function/arrow.

GrandmaGlassesRopeMan’s picture

Status: Needs work » Needs review
FileSize
2.51 KB
4.15 KB

- cleanup jsdoc
- cleanup coding standards issues.

✌️

lauriii’s picture

Sorry, I accidentally uploaded wrong patch on my comment #25. The patch in #25 is actually patch from #23. I tried to combine my changes with #29. Interdiff from #29.

GrandmaGlassesRopeMan’s picture

Status: Needs review » Needs work

Just some minor feedback ✌️

  1. +++ b/core/misc/ajax.es6.js
    @@ -811,6 +811,40 @@
    +   * @param {string|null} message
    

    Here's the docs for marking something as optional, as well as documenting default values. http://usejsdoc.org/tags-param.html#optional-parameters-and-default-values

  2. +++ b/core/misc/ajax.es6.js
    @@ -811,6 +811,40 @@
    +  Drupal.theme.ajaxProgressThrobber = (message = null) => {
    +    // Build markup without adding extra white space since it affects rendering.
    +    const messageMarkup = message !== null ? Drupal.theme('ajaxProgressMessage', message) : '';
    +    const throbber = '<div class="throbber">&nbsp;</div>';
    +
    +    return `<div class="ajax-progress ajax-progress-throbber">${throbber}${messageMarkup}</div>`;
    +  };
    

    Could this be simplified to to just an || operator, and return a multiline template string?

lauriii’s picture

Status: Needs work » Needs review
FileSize
5.54 KB
2.12 KB

#31.1: Not really. That will add some whitespaces to the rendered markup which will affect how the throbber is rendered when message is visible.

GrandmaGlassesRopeMan’s picture

I think what I was trying to say was something like, `<div class="ajax-progress ajax-progress-throbber"><div class="throbber">&nbsp;</div>${(message && Drupal.theme('ajaxProgressMessage', message)) || ''}</div>`

edit..

If you're interested in creating multi-line template strings, and your output is whitespace insensitive, you can use the \ to remove the new line characters that are inserted at transpile time.

Drupal.theme.ajaxProgressThrobber = message => `\
    <div class="ajax-progress ajax-progress-throbber">\
      <div class="throbber">&nbsp;</div>\
      ${(message && typeof message === 'string' && Drupal.theme('ajaxProgressMessage', message)) || ''}\
    </div>`;
lauriii’s picture

Updated the issue credits

GrandmaGlassesRopeMan’s picture

Status: Needs review » Reviewed & tested by the community

Alright. I think this looks good. 🎉👍

amietpatial’s picture

lokapujya’s picture

NM

markhalliwell’s picture

Thank you! This has been sorely needed for years! RTBC+++

lokapujya’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Someone has to say it: Needs Tests.

Is there a core theme that should use this feature? Found this #2775725: Update throbber icon.
or a test theme? Also, should this be documented somewhere?

Anonymous’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
7.63 KB
13.17 KB

To create this test, I took a hold_test module from #2828528-107: Add Quick Edit Functional JS test coverage. Because it help to avoid random fails due to the fact that the throbber will disappear faster than we will check it.

Testing takes place on the view page, there are all kinds of throbbers.

Test works with selenium, but with phantomjs too.

test-only is interdiff with #32.

Anonymous’s picture

Also, should this be documented somewhere?

+1 to CR

The last submitted patch, 40: 2407859-40-test-only.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 40: 2407859-40.patch, failed testing. View results

Anonymous’s picture

Status: Needs work » Needs review
Issue tags: +Needs change record
FileSize
7.62 KB
13.17 KB

Hah, Test Bot revealed my brazen copy-paste from namespace of views module :)

Actually, I'm not sure that I chose the right namespace. Throbber more relevant to UI than to AJAX, so feel free to point on namespace.

The last submitted patch, 44: 2407859-44-test-only.patch, failed testing. View results

lokapujya’s picture

I don't think it needs a CR because it isn't breaking anything, but was thinking the Theming Guide for the "
Drupal theming mechanism for JavaScript code." : www.drupal.org/docs/8/theming.

lauriii’s picture

@lokapujya We do change records for API additions and new features as well! It is great way to educate developers of this types of features 🚀

lauriii’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs change record

The latest patch looks good for me. Thank you so much @vaplas for the amazing work on adding the test coverage!

I also created a change record for this.

Anonymous’s picture

@lauriii, thank you! Added to CR info about ajaxProgressMessage too.

Also one nit c/p flaw in test name fixed. So still RTBC.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 49: 2407859-49.patch, failed testing. View results

Anonymous’s picture

Status: Needs work » Reviewed & tested by the community
webchick’s picture

Status: Reviewed & tested by the community » Fixed

This seems to have all the requisite sign-offs, and I pinged @lauriii for confirmation of this fact.

Committed and pushed to 8.x. Thanks!

Anonymous’s picture

Status: Fixed » Reviewed & tested by the community

🎉 Inspiring news! But notcommit?

heddn’s picture

Super excited to be able to swap this out. Now it will be much easier to make my client required dancing dog wait icon! Don't ask.

  • webchick committed bae2ff8 on 8.6.x
    Issue #2407859 by vaplas, lauriii, vprocessor, drpal, jwilson3,...
webchick’s picture

Status: Reviewed & tested by the community » Fixed

D'oh. git push is a whole thing. ;) Thanks, @vaplas!

@heddn: Pics or it didn't happen. :D

Anonymous’s picture

#56 Great thanks again, @webchick!

#54: Sure, this is the basic requirement to the site!

lauriii’s picture

#57: amazing! 😂🐾

heddn’s picture

FileSize
6.22 KB

dancing dog

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.