From 88f766bfc35e9ab27187df7da14b01c016fa1550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20Tisza?= Date: Thu, 1 May 2014 01:12:12 +0000 Subject: [PATCH] Reanimate metadata panel when viewer is reopened Change-Id: I776a27358b2da17a35234aa8cb649a49df4a651d Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/548 --- resources/mmv/ui/mmv.ui.metadataPanel.js | 7 +++++-- tests/qunit/mmv/ui/mmv.ui.metadataPanel.test.js | 12 +++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/resources/mmv/ui/mmv.ui.metadataPanel.js b/resources/mmv/ui/mmv.ui.metadataPanel.js index 66698fe32..8356a60a5 100644 --- a/resources/mmv/ui/mmv.ui.metadataPanel.js +++ b/resources/mmv/ui/mmv.ui.metadataPanel.js @@ -37,11 +37,11 @@ this.localStorage = localStorage; /** - * Whether we've fired an animation for the metadata div. + * Whether we've already fired an animation for the metadata div in this lightbox session. * @property {boolean} * @private */ - this.hasAnimatedMetadata = !this.localStorage || this.localStorage.getItem( 'mmv.hasOpenedMetadata' ); + this.hasAnimatedMetadata = undefined; /** @property {mw.mmv.HtmlUtils} htmlUtils - */ this.htmlUtils = new mw.mmv.HtmlUtils(); @@ -67,6 +67,9 @@ this.buttons.attach(); this.fileReuse.attach(); + + // reset animation flag when the viewer is reopened + this.hasAnimatedMetadata = !this.localStorage || this.localStorage.getItem( 'mmv.hasOpenedMetadata' ); }; MPP.unattach = function() { diff --git a/tests/qunit/mmv/ui/mmv.ui.metadataPanel.test.js b/tests/qunit/mmv/ui/mmv.ui.metadataPanel.test.js index 9c583ba4e..bd4ba4726 100644 --- a/tests/qunit/mmv/ui/mmv.ui.metadataPanel.test.js +++ b/tests/qunit/mmv/ui/mmv.ui.metadataPanel.test.js @@ -210,7 +210,7 @@ } ); - QUnit.test( 'Metadata div is only animated once', 4, function ( assert ) { + QUnit.test( 'Metadata div is only animated once', 5, function ( assert ) { var $qf = $( '#qunit-fixture' ), displayCount, panel = new mw.mmv.ui.MetadataPanel( $qf, $( '
' ).appendTo( $qf ), { @@ -219,6 +219,8 @@ setItem: function ( _, val ) { displayCount = val; } } ); + panel.attach(); + panel.animateMetadataOnce(); assert.ok( panel.hasAnimatedMetadata, @@ -233,6 +235,14 @@ assert.strictEqual( panel.hasAnimatedMetadata, true, 'The second call to animateMetadataOnce did not change the value of hasAnimatedMetadata' ); assert.ok( !$qf.hasClass( 'invite' ), 'The second call to animateMetadataOnce did not lead to an animation' ); + + panel.unattach(); + + panel.attach(); + + panel.animateMetadataOnce(); + assert.ok( $qf.hasClass( 'invite' ), + 'After closing and opening the viewer, the panel is animated again' ); } ); QUnit.test( 'Repo icon', 4, function ( assert ) {