2014-02-07 14:47:00 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the MediaWiki extension MultimediaViewer.
|
|
|
|
*
|
|
|
|
* MultimediaViewer 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.
|
|
|
|
*
|
|
|
|
* MultimediaViewer 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 MultimediaViewer. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
( function ( mw, $ ) {
|
|
|
|
var L;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @class mw.mmv.Logger
|
|
|
|
* Writes log entries
|
|
|
|
*/
|
|
|
|
function Logger() {}
|
|
|
|
|
|
|
|
L = Logger.prototype;
|
|
|
|
|
|
|
|
L.logActions = {
|
|
|
|
'thumbnail-link-click': 'User clicked on thumbnail to open lightbox.',
|
|
|
|
'enlarge-link-click': 'User clicked on enlarge link to open lightbox.',
|
|
|
|
'fullscreen-link-click': 'User clicked on fullscreen button in lightbox.',
|
|
|
|
'defullscreen-link-click': 'User clicked on button to return to normal lightbox view.',
|
|
|
|
'close-link-click': 'User clicked on the lightbox close button.',
|
2014-02-06 16:17:38 +00:00
|
|
|
'site-link-click': 'User clicked on the link to the file description page.'
|
2014-02-07 14:47:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Logs an action
|
|
|
|
* @param {string} action The key representing the action
|
|
|
|
* @param {boolean} skipEventLog True if we don't want the action to be recorded in the event log
|
|
|
|
* @param {Object} substitutions A list of variable subtitutions for parametrized action texts
|
|
|
|
*/
|
|
|
|
L.log = function ( action, skipEventLog, substitutions ) {
|
2014-02-11 13:25:39 +00:00
|
|
|
var translatedAction = this.logActions[action] || action;
|
2014-02-07 14:47:00 +00:00
|
|
|
|
|
|
|
if ( $.isPlainObject( substitutions ) ) {
|
|
|
|
$.each( substitutions, function( key, value ) {
|
2014-02-11 13:25:39 +00:00
|
|
|
translatedAction = translatedAction.replace( key, value );
|
2014-02-07 14:47:00 +00:00
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
2014-02-11 13:25:39 +00:00
|
|
|
mw.log( translatedAction );
|
2014-02-07 14:47:00 +00:00
|
|
|
|
|
|
|
if ( mw.eventLog && !skipEventLog ) {
|
|
|
|
mw.eventLog.logEvent( 'MediaViewer', {
|
|
|
|
version: '1.1',
|
|
|
|
action: action
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
mw.mmv.logger = new Logger();
|
|
|
|
}( mediaWiki, jQuery ) );
|