Bartosz Dziewoński has uploaded a new change for review.
https://gerrit.wikimedia.org/r/201486
Change subject: Support per-language icon versions in colorize-svg.js
......................................................................
Support per-language icon versions in colorize-svg.js
Using :lang() selectors ......
Change-Id: I47704bf9b643ef6e65f5bc138678439a55090773
---
M build/tasks/colorize-svg.js
1 file changed, 43 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/86/201486/1
diff --git a/build/tasks/colorize-svg.js b/build/tasks/colorize-svg.js
index d02d8c0..ce73427 100644
--- a/build/tasks/colorize-svg.js
+++ b/build/tasks/colorize-svg.js
@@ -170,11 +170,12 @@
return fileName;
}
- var selector, declarations, direction,
+ var selector, declarations, direction, lang, langSelector,
deferred = Q.defer(),
file = typeof this.file === 'string' ?
{ default: this.file } :
{ ltr: this.file.ltr, rtl: this.file.rtl },
+ moreLangs = this.file.lang || {},
name = this.name,
sourcePath = this.list.getPath(),
destinationPath = destination.getPath(),
@@ -206,6 +207,22 @@
path.join( sourcePath, file[ direction ] )
);
files[ path.join( destinationPath, file[ direction ] )
] = originalSvg[ direction ];
+
+ for ( lang in moreLangs ) {
+ if ( file[ direction ] === moreLangs[ lang ] ) {
+ continue;
+ }
+
+ // This will not work for selectors ending in a
pseudo-element.
+ langSelector = ':lang(' + lang + ')';
+ declarations = getDeclarations( moreLangs[ lang
] );
+ rules[ direction ].push( selector +
langSelector + ' {\n\t' + declarations + '\n}' );
+
+ originalSvg[ 'lang-' + lang ] = grunt.file.read(
+ path.join( sourcePath, moreLangs[ lang
] )
+ );
+ files[ path.join( destinationPath, moreLangs[
lang ] ) ] = originalSvg[ 'lang-' + lang ];
+ }
}
// Variants
@@ -242,6 +259,31 @@
variantizeFileName( file[ direction ],
variantName )
);
files[ destinationFilePath ] = variantSvg;
+
+ for ( lang in moreLangs ) {
+ if ( file[ direction ] === moreLangs[
lang ] ) {
+ continue;
+ }
+
+ langSelector = ':lang(' + lang + ')';
+ declarations = getDeclarations(
variantizeFileName( moreLangs[ lang ], variantName ) );
+ rules[ direction ].push( selector +
langSelector + ' {\n\t' + declarations + '\n}' );
+
+ variantSvg = originalSvg[ 'lang-' +
lang ].replace(
+ /<svg[^>]*>/, '$&<style>* {
fill: ' + variant.getColor() + ' }</style>'
+ );
+
+ if ( originalSvg[ 'lang-' + lang ] ===
variantSvg ) {
+ uncolorizableImages.push(
moreLangs[ lang ] );
+ continue;
+ }
+
+ destinationFilePath = path.join(
+ destinationPath,
+ variantizeFileName( moreLangs[
lang ], variantName )
+ );
+ files[ destinationFilePath ] =
variantSvg;
+ }
}
} );
--
To view, visit https://gerrit.wikimedia.org/r/201486
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I47704bf9b643ef6e65f5bc138678439a55090773
Gerrit-PatchSet: 1
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits