Debian Codegraph @

extensions/Echo/modules/ui/mw.echo.ui.ClonedNotificationItemWidget.js

raw symbols SCIP
1 ( function () {
2 /* global moment:false */
3 /**
4 * A wrapper widget for a fake, cloned notification. This is used
5 * for the fade in/out effects while reordering.
6 *
7 * @class
8 * @extends OO.ui.Widget
9 *
10 * @constructor
11 * @param {jQuery} $element A clone of an mw.echo.ui.NotificationItemWidget's $element
12 * @param {Object} [config] Configuration options
13 * @param {string} [config.timestamp] The timestamp for this cloned widget, in UTC and ISO 8601 format
14 * @param {boolean} [config.read=false] The read state for this cloned widget
15 * @param {boolean} [config.foreign=false] The foreignness state of this cloned widget
16 * @param {number} [config.id] The id for this cloned widget
17 */
18 mw.echo.ui.ClonedNotificationItemWidget = function MwEchoUiClonedNotificationItemWidget( $element, config ) {
19 config = config || {};
20
21 // Parent constructor
22 mw.echo.ui.ClonedNotificationItemWidget.super.call( this, config );
23
24 this.$element = $element;
25 this.timestamp = config.timestamp || moment.utc().format( 'YYYY-MM-DD[T]HH:mm:ss[Z]' );
26 this.read = !!config.read;
27 this.foreign = config.foreign === undefined ? true : config.foreign;
28 this.id = config.id;
29
30 this.$element.addClass( 'mw-echo-ui-clonedNotificationItemWidget' );
31 };
32
33 /* Initialization */
34 OO.inheritClass( mw.echo.ui.ClonedNotificationItemWidget, OO.ui.Widget );
35
36 /**
37 * Get the widget's timestamp
38 *
39 * @return {string} Timestamp in UTC, ISO 8601 format
40 */
41 mw.echo.ui.ClonedNotificationItemWidget.prototype.getTimestamp = function () {
42 return this.timestamp;
43 };
44
45 /**
46 * Get the widget's read state
47 *
48 * @return {boolean} Widget is read
49 */
50 mw.echo.ui.ClonedNotificationItemWidget.prototype.isRead = function () {
51 return this.read;
52 };
53
54 /**
55 * Get the widget's id
56 *
57 * @return {number} Widget id
58 */
59 mw.echo.ui.ClonedNotificationItemWidget.prototype.getId = function () {
60 return this.id;
61 };
62
63 /**
64 * The foreign state of this widget
65 *
66 * @return {boolean} This item widget is foreign
67 */
68 mw.echo.ui.ClonedNotificationItemWidget.prototype.isForeign = function () {
69 return this.foreign;
70 };
71
72 /**
73 * This widget is fake by definition.
74 *
75 * @return {boolean} true
76 */
77 mw.echo.ui.ClonedNotificationItemWidget.prototype.isFake = function () {
78 return true;
79 };
80
81 /**
82 * No-op
83 */
84 mw.echo.ui.ClonedNotificationItemWidget.prototype.resetInitiallyUnseen = function () {
85 };
86
87 }() );