mediawiki-extensions-Revisi.../modules/ext.RevisionSlider.Pointer.js
Adam Wight b900446572 Migrate JS to ES6
Reintroduces IIFE closures in test files because variables were
declared in the global namespace, and "const" now causes hard errors.

Bug: T339323
Change-Id: I69e9d7a29591137f185f3e5ab02dea590ec4dff6
2023-06-23 08:01:31 +02:00

63 lines
972 B
JavaScript

const PointerLine = require( './ext.RevisionSlider.PointerLine.js' ),
PointerView = require( './ext.RevisionSlider.PointerView.js' );
/**
* Module containing logic for the revision pointers
*
* @class Pointer
* @param {string} name
* @constructor
*/
function Pointer( name ) {
this.view = new PointerView( this, name );
this.line = new PointerLine( this, name );
}
$.extend( Pointer.prototype, {
/**
* @type {number}
*/
position: 0,
/**
* @type {PointerView}
*/
view: null,
/**
* @type {PointerLine}
*/
line: null,
/**
* @param {number} p
*/
setPosition: function ( p ) {
this.position = p;
this.getView().setDataPositionAttribute( p );
},
/**
* @return {number}
*/
getPosition: function () {
return this.position;
},
/**
* @return {PointerView}
*/
getView: function () {
return this.view;
},
/**
* @return {PointerLine}
*/
getLine: function () {
return this.line;
}
} );
module.exports = Pointer;