Arlolra has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/345970 )
Change subject: Add additional options to slideshow gallery ...................................................................... Add additional options to slideshow gallery Change-Id: I23b9afca9e74e9cd2e732efc3a5a2659eb36132a --- M lib/ext/Gallery/index.js M lib/ext/Gallery/modes.js M tests/parserTests.txt 3 files changed, 39 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid refs/changes/70/345970/1 diff --git a/lib/ext/Gallery/index.js b/lib/ext/Gallery/index.js index 39ceaeb..a039d22 100644 --- a/lib/ext/Gallery/index.js +++ b/lib/ext/Gallery/index.js @@ -31,6 +31,7 @@ if (modes.has(mode)) { this.mode = mode; } this.showfilename = (attrs.showfilename !== undefined); + this.showthumbnails = (attrs.showthumbnails !== undefined); this.caption = attrs.caption; this.class = attrs.class; }; diff --git a/lib/ext/Gallery/modes.js b/lib/ext/Gallery/modes.js index 1f7c7a4..78ec7e7 100644 --- a/lib/ext/Gallery/modes.js +++ b/lib/ext/Gallery/modes.js @@ -22,6 +22,7 @@ ul.setAttribute('class', cl); doc.body.appendChild(ul); this.perRow(opts, ul); + this.setAdditionalOptions(opts, ul); return ul; }; @@ -36,6 +37,8 @@ ].join(' ')); } }; + +Traditional.prototype.setAdditionalOptions = function(opts, ul) {}; Traditional.prototype.caption = function(opts, doc, ul, caption) { var li = doc.createElement('li'); @@ -191,13 +194,22 @@ box.appendChild(wrapper); }; +var Slideshow = function(options) { + Traditional.call(this, options); +}; +coreutil.inherits(Slideshow, Traditional); + +Slideshow.prototype.setAdditionalOptions = function(opts, ul) { + ul.setAttribute('data-showthumbnails', opts.showthumbnails ? "1" : ""); +}; + var modes = JSUtils.mapObject({ traditional: new Traditional({}), nolines: new Traditional({ mode: 'nolines', padding: { thumb: 0, box: 5, border: 4 }, }), - slideshow: new Traditional({ mode: 'slideshow' }), + slideshow: new Slideshow({ mode: 'slideshow' }), packed: new Packed({}), 'packed-hover': new Packed({ mode: 'packed-hover' }), 'packed-overlay': new Packed({ mode: 'packed-overlay' }), diff --git a/tests/parserTests.txt b/tests/parserTests.txt index cb0001f..029de3a 100644 --- a/tests/parserTests.txt +++ b/tests/parserTests.txt @@ -19684,6 +19684,31 @@ !! end !! test +Gallery in slideshow mode +!! options +parsoid={ + "nativeGallery": true +} +!! wikitext +<gallery mode="slideshow" showthumbnails=""> +File:Foobar.jpg +</gallery> +!! html/php +<ul class="gallery mw-gallery-slideshow" data-showthumbnails="1"> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> + </div> + </div></li> +</ul> + +!! html/parsoid +<ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li> +</ul> +!! end + +!! test HTML Hex character encoding (spells the word "JavaScript") !! options parsoid=wt2html,wt2wt,html2html -- To view, visit https://gerrit.wikimedia.org/r/345970 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I23b9afca9e74e9cd2e732efc3a5a2659eb36132a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: Arlolra <abrea...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits