Skip to content

Commit

Permalink
Harmonize resource loading spinner (#788)
Browse files Browse the repository at this point in the history
* remove redundant module

* use global spinner

* replace spinner with srf-loading-dots

* fix requireResource

* add srf-loading-dots hide

* edit spinner padding

* fix spinner
  • Loading branch information
thomas-topway-it committed Oct 24, 2023
1 parent f77e599 commit b148377
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 25 deletions.
7 changes: 1 addition & 6 deletions Resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,7 @@
'ext.srf' => $moduleTemplate + [
'scripts' => 'resources/ext.srf.js',
'styles' => [
'resources/ext.srf.css',

// Someone broke the CSS loading (Suspect bug 46401) in 1.22
// until this is fixed force styles to be loaded at the very start
// to avoid display clutter
'formats/calendar/resources/ext.srf.formats.eventcalendar.css',
'resources/ext.srf.css'
],
'dependencies' => 'ext.smw.api',
'position' => 'top',
Expand Down
9 changes: 2 additions & 7 deletions SemanticResultFormats.utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,11 @@ final class SRFUtils {
* @since 1.8
*/
public static function htmlProcessingElement( $isHtml = true ) {
SMWOutputs::requireResource( 'ext.srf' );
SMWOutputs::requireResource( 'ext.smw.style' );

return Html::rawElement(
'div',
[ 'class' => 'srf-spinner mw-small-spinner' ],
Html::element(
'span',
[ 'class' => 'srf-processing-text' ],
wfMessage( 'srf-module-loading' )->inContentLanguage()->text()
)
[ 'class' => 'srf-loading-dots' ]
);
}

Expand Down
2 changes: 1 addition & 1 deletion resources/ext.srf.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

.srf-loading-dots {
background: url('data:image/gif;base64,R0lGODlhIgAUAMQRAOjp6dTW19ze3+Xm54iKjevs7IKEh/f396Olp5ianPz8/Judn9fY2YGDhp+ho4CChdHT1P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/wtYTVAgRGF0YVhNUDw/eHBh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bj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PgH//v38+/r5+Pf29fTz8vHw7+7t7Ovq6ejn5uXk4+Lh4N/e3dzb2tnY19bV1NPS0dDPzs3My8rJyMfGxcTDwsHAv769vLu6ubi3trW0s7KxsK+urayrqqmop6alpKOioaCfnp2cm5qZmJeWlZSTkpGQj46NjIuKiYiHhoWEg4KBgH9+fXx7enl4d3Z1dHNycXBvbm1sa2ppaGdmZWRjYmFgX15dXFtaWVhXVlVUU1JRUE9OTUxLSklIR0ZFRENCQUA/Pj08Ozo5ODc2NTQzMjEwLy4tLCsqKSgnJiUkIyIhIB8eHRwbGhkYFxYVFBMSERAPDg0MCwoJCAcGBQQDAgEAACH5BAkyABEALAAAAAAiABQAAAVeYCSOZGmeaKqubOu+cCzPdM0iBIGYgCAUPB8Q5XgYHw4SAMKEAJRNJ8pwfBhIgagAq0U1qg1ukyFmkk+L6oI0iD5H7ebbdEgYEweSYhAIDEp7fX82hIWGh4iJiosoIQAh+QQJMgARACwAAAAAIgAUAAAFZGAkjmRpnmiqrmzrvnAsz3TNFoIAmAhBICZArpACQI6Q3cjxaD4cJCNSaRIgIQGSwfkwkAJXAYpxzY4a3Mb3ykBJjwPSgrsgDa5U0yAQGChIBwlNCQckCnt9NoqLjI2Oj5CRKSEAIfkEBTIAEQAsAAAAACIAFAAABWNgJI5kaZ5oqq5s675wLM90zRaCAJi4biIEAiIFgBghu1HxmBQ5HtCHAyU4QgKk6hE7MkQfBhTDyhWNt6TGt4FaGgckNwQ+WnwXqUEgMFCU9Hx+IwcJUAkHNomKi4yNjo+QKCEAOw==') no-repeat left center;
padding: 5px 0 5px 35px;
padding: 24px 0 24px 35px;
vertical-align: middle;
}

Expand Down
3 changes: 2 additions & 1 deletion resources/ext.srf.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
hide: function ( options ){
var c = options.length === undefined ? options.context : options;
c.find( '.' + _CL_srfspinner ).hide();
c.find(".srf-loading-dots").hide();
}
},

Expand Down Expand Up @@ -361,4 +362,4 @@
}
};

} )( jQuery, mediaWiki, semanticFormats );
} )( jQuery, mediaWiki, semanticFormats );
8 changes: 2 additions & 6 deletions src/ResourceFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use SMWOutputs as ResourceManager;
use SMWQueryResult as QueryResult;
use SMW\Query\PrintRequest;
use SRFUtils;

/**
* @since 3.0
Expand Down Expand Up @@ -50,12 +51,7 @@ public static function session() {
* @since 3.0
*/
public static function placeholder() {
self::registerResources( [], [ 'ext.smw.style' ] );

return Html::rawElement(
'div',
[ 'class' => 'srf-loading-dots' ]
);
return SRFUtils::htmlProcessingElement();
}

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/phpunit/Integration/JSONScript/TestCases/media-01.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"subject": "Test/Mediaplayer test 01",
"assert-output": {
"to-contain": [
"<div class=\"srf-media\"><div class=\"srf-spinner mw-small-spinner\"><span class=\"srf-processing-text\">Loading...</span></div><div id=\"srf-.*\" class=\"media-container\" style=\"display:none;\"></div></div>"
"<div class=\"srf-media\"><div class=\"srf-loading-dots\"></div><div id=\"srf-.*\" class=\"media-container\" style=\"display:none;\"></div></div>"
]
}
},
Expand All @@ -45,7 +45,7 @@
"subject": "Test/Mediaplayer test 02",
"assert-output": {
"to-contain": [
"<div class=\"srf-media\"><div class=\"srf-spinner mw-small-spinner\"><span class=\"srf-processing-text\">Loading...</span></div><div id=\"srf-.*\" class=\"media-container\" style=\"display:none;\"></div></div>"
"<div class=\"srf-media\"><div class=\"srf-loading-dots\"></div><div id=\"srf-.*\" class=\"media-container\" style=\"display:none;\"></div></div>"
]
}
},
Expand All @@ -55,7 +55,7 @@
"subject": "Test/Mediaplayer test 03",
"assert-output": {
"to-contain": [
"<div class=\"srf-media\"><div class=\"srf-spinner mw-small-spinner\"><span class=\"srf-processing-text\">Loading...</span></div><div id=\"srf-.*\" class=\"media-container\" style=\"display:none;\"></div></div>"
"<div class=\"srf-media\"><div class=\"srf-loading-dots\"></div><div id=\"srf-.*\" class=\"media-container\" style=\"display:none;\"></div></div>"
]
}
}
Expand All @@ -75,4 +75,4 @@
"is-incomplete": false,
"debug": false
}
}
}

0 comments on commit b148377

Please sign in to comment.