2014-04-01 01:41:57 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the MediaWiki extension MediaViewer.
|
|
|
|
*
|
|
|
|
* MediaViewer is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MediaViewer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with MediaViewer. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
( function( mw, $, oo ) {
|
|
|
|
var SBP;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @class mw.mmv.ui.StripeButtons
|
|
|
|
* @extends mw.mmv.ui.Element
|
|
|
|
* Class for buttons which are placed on the metadata stripe (the always visible part of the
|
|
|
|
* metadata panel).
|
|
|
|
* @constructor
|
|
|
|
* @param {jQuery} $container
|
2014-04-08 09:54:30 +00:00
|
|
|
* @param {Object} localStorage the localStorage object, for dependency injection
|
2014-04-01 01:41:57 +00:00
|
|
|
*/
|
2014-04-08 09:54:30 +00:00
|
|
|
function StripeButtons( $container, localStorage ) {
|
2014-04-01 01:41:57 +00:00
|
|
|
mw.mmv.ui.Element.call( this, $container );
|
|
|
|
|
2014-04-08 09:54:30 +00:00
|
|
|
/** @property {Object} localStorage the window.localStorage object */
|
|
|
|
this.localStorage = localStorage;
|
|
|
|
|
2014-04-01 01:41:57 +00:00
|
|
|
this.$buttonContainer = $( '<div>' )
|
|
|
|
.addClass( 'mw-mmv-stripe-button-container' )
|
|
|
|
.appendTo( $container );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This holds the actual buttons.
|
|
|
|
* @property {Object.<string, jQuery>}
|
|
|
|
*/
|
|
|
|
this.buttons = {};
|
|
|
|
|
2014-04-08 09:37:24 +00:00
|
|
|
if ( this.shouldShowFeedbackSurvey() ) {
|
|
|
|
this.initFeedbackButton();
|
|
|
|
}
|
2014-04-01 01:41:57 +00:00
|
|
|
this.initReuseButton();
|
2014-06-09 06:56:52 +00:00
|
|
|
this.initDescriptionPageButton();
|
2014-04-01 01:41:57 +00:00
|
|
|
}
|
|
|
|
oo.inheritClass( StripeButtons, mw.mmv.ui.Element );
|
|
|
|
SBP = StripeButtons.prototype;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @protected
|
|
|
|
* Creates a new button on the metadata stripe.
|
|
|
|
* @param {string} cssClass CSS class name for the button
|
|
|
|
* @param {string} text HTML code for the button text
|
2014-04-01 19:02:33 +00:00
|
|
|
* @param {string} popupText HTML code for the popup text
|
2014-04-01 01:41:57 +00:00
|
|
|
*/
|
2014-04-01 19:02:33 +00:00
|
|
|
SBP.createButton = function ( cssClass, text, popupText ) {
|
2014-05-31 00:18:12 +00:00
|
|
|
var tooltipDelay = mw.config.get( 'wgMultimediaViewer' ).tooltipDelay;
|
|
|
|
|
2014-04-01 19:02:33 +00:00
|
|
|
return $( '<a>' )
|
2014-04-01 01:41:57 +00:00
|
|
|
.addClass( 'mw-mmv-stripe-button empty ' + cssClass )
|
2014-04-02 01:58:41 +00:00
|
|
|
// .text( text ) // disabled while we have 3 buttons to save space
|
2014-04-01 19:02:33 +00:00
|
|
|
.prop( 'title', popupText )
|
2014-04-01 01:41:57 +00:00
|
|
|
// elements are right-floated so we use prepend instead of append to keep the order
|
2014-04-02 00:39:54 +00:00
|
|
|
.prependTo( this.$buttonContainer )
|
2014-05-31 00:18:12 +00:00
|
|
|
.tipsy( {
|
|
|
|
gravity: $( document.body ).hasClass( 'rtl' ) ? 'sw' : 'se',
|
|
|
|
delayIn: tooltipDelay
|
|
|
|
} );
|
2014-04-01 01:41:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @protected
|
|
|
|
* Creates the reuse button.
|
|
|
|
*/
|
|
|
|
SBP.initReuseButton = function() {
|
|
|
|
this.buttons.$reuse = this.createButton(
|
|
|
|
'mw-mmv-stripe-button-reuse',
|
2014-04-02 01:58:41 +00:00
|
|
|
mw.message( 'multimediaviewer-reuse-link' ).text(),
|
2014-04-01 01:41:57 +00:00
|
|
|
mw.message( 'multimediaviewer-reuse-link' ).text()
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2014-04-02 01:58:41 +00:00
|
|
|
/**
|
|
|
|
* @protected
|
|
|
|
* Creates a button linking to the file description page.
|
|
|
|
*/
|
2014-04-02 00:07:51 +00:00
|
|
|
SBP.initDescriptionPageButton = function() {
|
|
|
|
this.buttons.$descriptionPage = this.createButton(
|
|
|
|
'mw-mmv-stripe-button-commons',
|
|
|
|
mw.message( 'multimediaviewer-description-page-button-text' ).plain()
|
2014-06-18 00:50:42 +00:00
|
|
|
).click( function () {
|
|
|
|
mw.mmv.actionLogger.log( 'file-description-page-abovefold' );
|
|
|
|
} );
|
|
|
|
|
2014-04-02 00:07:51 +00:00
|
|
|
};
|
|
|
|
|
2014-04-01 19:02:33 +00:00
|
|
|
/**
|
|
|
|
* @protected
|
|
|
|
* Creates the feedback button.
|
|
|
|
*/
|
|
|
|
SBP.initFeedbackButton = function() {
|
2014-04-01 21:58:04 +00:00
|
|
|
var buttons = this;
|
|
|
|
|
2014-04-01 19:02:33 +00:00
|
|
|
this.buttons.$feedback = this.createButton(
|
|
|
|
'mw-mmv-stripe-button-feedback',
|
|
|
|
mw.message( 'multimediaviewer-feedback-button-text' ).plain(),
|
|
|
|
mw.message( 'multimediaviewer-feedback-popup-text' ).plain()
|
2014-04-02 00:39:54 +00:00
|
|
|
).attr( {
|
2014-04-01 19:02:33 +00:00
|
|
|
target: '_blank',
|
2014-04-01 21:58:04 +00:00
|
|
|
href: this.getFeedbackSurveyUrl()
|
|
|
|
} ).click( function ( e ) {
|
|
|
|
buttons.openSurveyInNewWindow();
|
2014-04-08 09:54:30 +00:00
|
|
|
buttons.maxOutTooltipDisplayCount();
|
2014-04-01 21:58:04 +00:00
|
|
|
e.preventDefault();
|
|
|
|
} );
|
|
|
|
};
|
|
|
|
|
2014-04-08 09:54:30 +00:00
|
|
|
SBP.feedbackSettings = {
|
|
|
|
/** Show the tooltip this many seconds to get the user's attention, even when it is not hovered. */
|
|
|
|
tooltipDisplayDuration: 5,
|
|
|
|
/** Wait for this long after the viewer is opened, before showing the tooltip. */
|
|
|
|
tooltipDelay: 5,
|
|
|
|
/** Only show the tooltip this many times */
|
|
|
|
tooltipMaxDisplayCount: 3
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2014-05-01 10:00:31 +00:00
|
|
|
* Returns the number of times the tooltip was shown so far. This number is set to this.feedbackSettings.tooltipMaxDisplayCount if the
|
2014-04-08 09:54:30 +00:00
|
|
|
* user clicked on the link already, or we cannot count how many times the tooltip was shown
|
|
|
|
* already.
|
|
|
|
* @return {number}
|
|
|
|
*/
|
|
|
|
SBP.getTooltipDisplayCount = function () {
|
|
|
|
if ( !this.localStorage ) {
|
2014-05-01 10:00:31 +00:00
|
|
|
return this.feedbackSettings.tooltipMaxDisplayCount;
|
2014-04-08 09:54:30 +00:00
|
|
|
}
|
|
|
|
if ( this.tooltipDisplayCount === undefined ) {
|
|
|
|
this.tooltipDisplayCount = this.localStorage.getItem( 'mmv.tooltipDisplayCount' );
|
|
|
|
if ( this.tooltipDisplayCount === null ) {
|
|
|
|
this.tooltipDisplayCount = 0;
|
2014-05-01 10:00:31 +00:00
|
|
|
try {
|
|
|
|
this.localStorage.setItem( 'mmv.tooltipDisplayCount', 0 );
|
|
|
|
} catch ( e ) {
|
|
|
|
// localStorage is full or disabled
|
|
|
|
this.tooltipDisplayCount = this.feedbackSettings.tooltipMaxDisplayCount;
|
|
|
|
}
|
2014-04-08 09:54:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return this.tooltipDisplayCount;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Increases tooltip display count.
|
|
|
|
*/
|
|
|
|
SBP.increaseTooltipDisplayCount = function () {
|
|
|
|
this.getTooltipDisplayCount();
|
2014-05-01 10:00:31 +00:00
|
|
|
if ( this.tooltipDisplayCount !== undefined && this.tooltipDisplayCount < this.feedbackSettings.tooltipMaxDisplayCount ) {
|
2014-04-08 09:54:30 +00:00
|
|
|
this.tooltipDisplayCount++;
|
2014-05-01 10:00:31 +00:00
|
|
|
|
|
|
|
if ( this.localStorage ) {
|
|
|
|
try {
|
|
|
|
this.localStorage.setItem( 'mmv.tooltipDisplayCount', this.tooltipDisplayCount );
|
|
|
|
} catch ( e ) {
|
|
|
|
// localStorage is full or disabled
|
|
|
|
}
|
|
|
|
}
|
2014-04-08 09:54:30 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets tooltip display count so large that the tooltip will never be shown again.
|
|
|
|
* We use this for users who already opened the form.
|
|
|
|
*/
|
|
|
|
SBP.maxOutTooltipDisplayCount = function () {
|
|
|
|
this.getTooltipDisplayCount();
|
|
|
|
if ( this.tooltipDisplayCount !== undefined ) {
|
2014-05-01 10:00:31 +00:00
|
|
|
this.tooltipDisplayCount = this.feedbackSettings.tooltipMaxDisplayCount;
|
|
|
|
|
|
|
|
if ( this.localStorage ) {
|
|
|
|
try {
|
|
|
|
this.localStorage.setItem( 'mmv.tooltipDisplayCount', this.tooltipDisplayCount );
|
|
|
|
} catch ( e ) {
|
|
|
|
// localStorage is full or disabled
|
|
|
|
}
|
|
|
|
}
|
2014-04-08 09:54:30 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the tooltip to the user if it was not shown often enough yet.
|
|
|
|
*/
|
|
|
|
SBP.maybeDisplayTooltip = function () {
|
|
|
|
if (
|
|
|
|
this.readyToShowFeedbackTooltip &&
|
|
|
|
this.getTooltipDisplayCount() < this.feedbackSettings.tooltipMaxDisplayCount
|
|
|
|
) {
|
|
|
|
this.buttons.$feedback.tipsy( 'show' );
|
|
|
|
this.setTimer( 'feedbackTooltip.hide', function () {
|
|
|
|
this.buttons.$feedback.tipsy( 'hide' );
|
|
|
|
}, this.feedbackSettings.tooltipDisplayDuration * 1000 );
|
|
|
|
this.increaseTooltipDisplayCount();
|
|
|
|
this.readyToShowFeedbackTooltip = false;
|
|
|
|
} else {
|
|
|
|
// if the tooltip is visible already, make sure it is not hidden too quickly
|
|
|
|
this.resetTimer( 'feedbackTooltip.hide' );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-04-15 02:43:17 +00:00
|
|
|
/**
|
|
|
|
* Returns a link to a survey in the given language or null if that language is not supported
|
|
|
|
* @param {string|null} langcode
|
|
|
|
*/
|
|
|
|
SBP.getFeedbackSurveyBaseUrlForLanguage = function ( langcode ) {
|
2014-04-22 21:55:57 +00:00
|
|
|
var baseLangcode,
|
|
|
|
baseUrl = 'https://www.surveymonkey.com/s/media-viewer-1',
|
2014-04-28 22:33:13 +00:00
|
|
|
surveyTranslations = { ca: 'ca', hu: 'hu', fr: 'fr', pt: 'pt-br', 'pt-br': 'pt-br',
|
2014-04-29 19:16:11 +00:00
|
|
|
de: 'de', es: 'es', nl: 'nl' };
|
2014-04-15 02:43:17 +00:00
|
|
|
|
2014-04-22 21:55:57 +00:00
|
|
|
baseLangcode = langcode.split( /[_-]/ )[0]; // get rid of variants
|
|
|
|
if ( baseLangcode === 'en') {
|
2014-04-15 02:43:17 +00:00
|
|
|
return baseUrl;
|
|
|
|
} else if ( surveyTranslations[langcode] ) {
|
2014-04-22 21:55:57 +00:00
|
|
|
return baseUrl + '-' + surveyTranslations[langcode];
|
|
|
|
} else if ( surveyTranslations[baseLangcode] ) {
|
|
|
|
return baseUrl + '-' + surveyTranslations[baseLangcode];
|
2014-04-15 02:43:17 +00:00
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a link to a survey in the user language, or null if not supported
|
|
|
|
*/
|
|
|
|
SBP.getFeedbackSurveyBaseUrl = function () {
|
|
|
|
return this.getFeedbackSurveyBaseUrlForLanguage( mw.config.get( 'wgUserLanguage' ) );
|
|
|
|
};
|
|
|
|
|
2014-04-08 09:37:24 +00:00
|
|
|
/**
|
|
|
|
* Checks if it is suitable to show a survey to the current user.
|
|
|
|
*/
|
|
|
|
SBP.shouldShowFeedbackSurvey = function () {
|
|
|
|
return mw.config.get( 'wgMultimediaViewer' ).showSurvey &&
|
2014-04-15 02:43:17 +00:00
|
|
|
this.getFeedbackSurveyBaseUrl();
|
2014-04-08 09:37:24 +00:00
|
|
|
};
|
|
|
|
|
2014-04-02 01:58:41 +00:00
|
|
|
/**
|
|
|
|
* Generates a survey URL (currently constant but the possibility of splitting by
|
|
|
|
* editor cohort was mentioned).
|
|
|
|
* @return {string}
|
|
|
|
*/
|
2014-04-01 21:58:04 +00:00
|
|
|
SBP.getFeedbackSurveyUrl = function () {
|
2014-04-15 02:43:17 +00:00
|
|
|
return this.getFeedbackSurveyBaseUrl() + '?c=' + mw.config.get( 'wgDBname' );
|
2014-04-01 21:58:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens the survey in a new window, or brings it up if it is already opened.
|
|
|
|
*/
|
|
|
|
SBP.openSurveyInNewWindow = function () {
|
|
|
|
var surveyWindowWidth = screen.width * 0.85,
|
|
|
|
surveyWindowHeight = screen.height * 0.85,
|
|
|
|
feedbackSurveyWindowProperties = {
|
|
|
|
left: ( screen.width - surveyWindowWidth ) / 2,
|
|
|
|
top: ( screen.height - surveyWindowHeight ) / 2,
|
|
|
|
width: surveyWindowWidth,
|
|
|
|
height: surveyWindowHeight,
|
|
|
|
menubar: 0,
|
|
|
|
toolbar: 0,
|
|
|
|
location: 0,
|
|
|
|
personalbar: 0,
|
2014-04-18 21:24:15 +00:00
|
|
|
status: 0,
|
|
|
|
scrollbars: 1
|
2014-04-01 21:58:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if ( !this.surveyWindow || this.surveyWindow.closed ) {
|
|
|
|
this.surveyWindow = window.open( this.getFeedbackSurveyUrl(), 'mmv-survey',
|
|
|
|
this.createWindowOpenPropertyString( feedbackSurveyWindowProperties ) );
|
|
|
|
} else {
|
|
|
|
this.surveyWindow.focus();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @protected
|
|
|
|
* Takes a property object and turns it into a string suitable for the last parameter
|
|
|
|
* of window.open.
|
|
|
|
* @param {Object} properties
|
|
|
|
* @return {string}
|
|
|
|
*/
|
|
|
|
SBP.createWindowOpenPropertyString = function ( properties ) {
|
|
|
|
var propertyArray = [];
|
|
|
|
$.each( properties, function ( key, value ) {
|
|
|
|
propertyArray.push( key + '=' + value );
|
2014-04-01 19:02:33 +00:00
|
|
|
} );
|
2014-04-01 21:58:04 +00:00
|
|
|
return propertyArray.join( ',' );
|
2014-04-01 19:02:33 +00:00
|
|
|
};
|
|
|
|
|
2014-04-01 01:41:57 +00:00
|
|
|
/**
|
|
|
|
* @protected
|
|
|
|
* Runs code for each button, similarly to $.each.
|
|
|
|
* @param {function(jQuery, string)} callback a function that will be called with each button
|
|
|
|
*/
|
|
|
|
SBP.eachButton = function ( callback ) {
|
|
|
|
var buttonName;
|
|
|
|
for ( buttonName in this.buttons ) {
|
|
|
|
callback( this.buttons[buttonName], buttonName );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
2014-04-02 00:07:51 +00:00
|
|
|
* @param {mw.mmv.model.Image} imageInfo
|
|
|
|
* @param {mw.mmv.model.Repo} repoInfo
|
2014-04-01 01:41:57 +00:00
|
|
|
*/
|
2014-04-02 00:07:51 +00:00
|
|
|
SBP.set = function ( imageInfo, repoInfo ) {
|
2014-04-01 01:41:57 +00:00
|
|
|
this.eachButton( function ( $button ) {
|
|
|
|
$button.removeClass( 'empty' );
|
|
|
|
} );
|
2014-04-02 00:07:51 +00:00
|
|
|
|
2014-06-09 06:56:52 +00:00
|
|
|
this.setDescriptionPageButton( imageInfo, repoInfo );
|
2014-04-08 09:54:30 +00:00
|
|
|
|
2014-04-10 01:09:07 +00:00
|
|
|
if ( this.shouldShowFeedbackSurvey() ) {
|
|
|
|
this.maybeDisplayTooltip();
|
|
|
|
}
|
2014-04-02 00:49:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @protected
|
|
|
|
* Updates the button linking to the file page.
|
|
|
|
* @param {mw.mmv.model.Image} imageInfo
|
|
|
|
* @param {mw.mmv.model.Repo} repoInfo
|
|
|
|
*/
|
|
|
|
SBP.setDescriptionPageButton = function ( imageInfo, repoInfo ) {
|
|
|
|
var descPagePopupMessage;
|
|
|
|
|
2014-04-02 00:07:51 +00:00
|
|
|
descPagePopupMessage = repoInfo.isLocal
|
2014-04-04 19:02:36 +00:00
|
|
|
? mw.message( 'multimediaviewer-description-page-button-text' ).plain()
|
2014-05-01 00:04:09 +00:00
|
|
|
: mw.message( 'multimediaviewer-description-page-popup-text', repoInfo.displayName ).text();
|
2014-04-02 00:07:51 +00:00
|
|
|
|
2014-04-02 00:39:54 +00:00
|
|
|
this.buttons.$descriptionPage.attr( {
|
2014-04-02 00:07:51 +00:00
|
|
|
href: imageInfo.descriptionUrl,
|
2014-04-02 00:39:54 +00:00
|
|
|
title: descPagePopupMessage,
|
|
|
|
'original-title': descPagePopupMessage // needed by jquery.tipsy
|
2014-04-02 00:07:51 +00:00
|
|
|
} );
|
|
|
|
|
2014-06-02 21:24:32 +00:00
|
|
|
if ( repoInfo.isCommons() ) {
|
2014-04-02 00:07:51 +00:00
|
|
|
this.buttons.$descriptionPage.addClass( 'mw-mmv-stripe-button-commons' );
|
|
|
|
} else {
|
|
|
|
this.buttons.$descriptionPage.addClass( 'mw-mmv-stripe-button-dynamic' );
|
2014-04-10 19:09:28 +00:00
|
|
|
if ( repoInfo.favIcon ) {
|
|
|
|
this.setInlineStyle( 'stripe-button-description-page',
|
|
|
|
// needs to be more specific then the fallback rule in stripeButtons.less
|
|
|
|
'.mw-mmv-stripe-button-container .mw-mmv-stripe-button-dynamic:before {' +
|
|
|
|
'background-image: url("' + repoInfo.favIcon + '");' +
|
|
|
|
'}'
|
|
|
|
);
|
|
|
|
}
|
2014-04-02 00:07:51 +00:00
|
|
|
}
|
2014-04-01 01:41:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
SBP.empty = function () {
|
|
|
|
this.eachButton( function ( $button ) {
|
2014-04-02 00:07:51 +00:00
|
|
|
$button.addClass( 'empty' );
|
2014-04-01 01:41:57 +00:00
|
|
|
} );
|
2014-04-02 00:07:51 +00:00
|
|
|
|
|
|
|
this.buttons.$reuse.removeClass( 'open' );
|
2014-06-09 06:56:52 +00:00
|
|
|
|
|
|
|
this.buttons.$descriptionPage.attr( { href: null, title: null, 'original-title': null } )
|
|
|
|
.removeClass( 'mw-mmv-stripe-button-dynamic mw-mmv-stripe-button-commons' );
|
|
|
|
$( '.mw-mmv-stripe-button-dynamic-before' ).remove();
|
|
|
|
this.setInlineStyle( 'stripe-button-description-page', null );
|
2014-04-01 01:41:57 +00:00
|
|
|
};
|
|
|
|
|
2014-04-02 01:58:41 +00:00
|
|
|
/**
|
|
|
|
* @event mmv-reuse-open
|
|
|
|
* Fired when the buttonto open the reuse dialog is clicked.
|
|
|
|
*/
|
2014-04-01 01:41:57 +00:00
|
|
|
/**
|
|
|
|
* Registers listeners.
|
|
|
|
*/
|
|
|
|
SBP.attach = function () {
|
|
|
|
var buttons = this.buttons;
|
|
|
|
|
|
|
|
buttons.$reuse.on( 'click.mmv-stripeButtons', function ( e ) {
|
|
|
|
$( document ).trigger( 'mmv-reuse-open' );
|
|
|
|
e.stopPropagation(); // the dialog would take it as an outside click and close
|
|
|
|
} );
|
|
|
|
this.handleEvent( 'mmv-reuse-opened', function () {
|
|
|
|
buttons.$reuse.addClass( 'open' );
|
|
|
|
} );
|
|
|
|
this.handleEvent( 'mmv-reuse-closed', function () {
|
|
|
|
buttons.$reuse.removeClass( 'open' );
|
|
|
|
} );
|
2014-04-08 09:54:30 +00:00
|
|
|
|
2014-04-10 01:24:21 +00:00
|
|
|
if ( this.shouldShowFeedbackSurvey() ) {
|
|
|
|
this.readyToShowFeedbackTooltip = false;
|
|
|
|
this.setTimer( 'feedbackTooltip.show', function () {
|
|
|
|
this.readyToShowFeedbackTooltip = true;
|
|
|
|
this.maybeDisplayTooltip();
|
|
|
|
}, this.feedbackSettings.tooltipDelay * 1000 );
|
|
|
|
}
|
2014-04-01 01:41:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clears listeners.
|
|
|
|
*/
|
|
|
|
SBP.unattach = function () {
|
2014-04-07 17:37:42 +00:00
|
|
|
this.constructor['super'].prototype.unattach.call( this );
|
2014-04-01 01:41:57 +00:00
|
|
|
this.buttons.$reuse.off( 'click.mmv-stripeButtons' );
|
2014-04-08 09:54:30 +00:00
|
|
|
|
|
|
|
this.clearTimer( 'feedbackTooltip.show' );
|
2014-06-27 19:45:45 +00:00
|
|
|
|
|
|
|
$.each( this.buttons, function ( name, $button ) {
|
|
|
|
$button.tipsy( 'hide' );
|
|
|
|
} );
|
2014-04-01 01:41:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
mw.mmv.ui.StripeButtons = StripeButtons;
|
|
|
|
}( mediaWiki, jQuery, OO ) );
|