Debian Codegraph @

extensions/VisualEditor/lib/ve/src/dm/selections/ve.dm.NullSelection.js

raw symbols SCIP
1 /*!
2 * VisualEditor Null Selection class.
3 *
4 * @copyright See AUTHORS.txt
5 */
6
7 /**
8 * @class
9 * @extends ve.dm.Selection
10 * @constructor
11 */
12 ve.dm.NullSelection = function VeDmNullSelection() {
13 // Parent constructor
14 ve.dm.NullSelection.super.call( this );
15 };
16
17 /* Inheritance */
18
19 OO.inheritClass( ve.dm.NullSelection, ve.dm.Selection );
20
21 /* Static Properties */
22
23 ve.dm.NullSelection.static.name = 'null';
24
25 /* Static Methods */
26
27 /**
28 * @inheritdoc
29 */
30 ve.dm.NullSelection.static.newFromHash = function () {
31 return new ve.dm.NullSelection();
32 };
33
34 /* Methods */
35
36 /**
37 * @inheritdoc
38 */
39 ve.dm.NullSelection.prototype.toJSON = function () {
40 return {
41 type: this.constructor.static.name
42 };
43 };
44
45 /**
46 * @inheritdoc
47 */
48 ve.dm.NullSelection.prototype.getDescription = function () {
49 return 'Null';
50 };
51
52 /**
53 * Used as a shortcut for methods which make no modification
54 *
55 * @private
56 * @return {ve.dm.NullSelection} The selection itself
57 */
58 ve.dm.NullSelection.prototype.self = function () {
59 return this;
60 };
61
62 ve.dm.NullSelection.prototype.collapseToStart = ve.dm.NullSelection.prototype.self;
63
64 ve.dm.NullSelection.prototype.collapseToEnd = ve.dm.NullSelection.prototype.self;
65
66 ve.dm.NullSelection.prototype.collapseToFrom = ve.dm.NullSelection.prototype.self;
67
68 ve.dm.NullSelection.prototype.collapseToTo = ve.dm.NullSelection.prototype.self;
69
70 /**
71 * @inheritdoc
72 */
73 ve.dm.NullSelection.prototype.isCollapsed = function () {
74 return true;
75 };
76
77 ve.dm.NullSelection.prototype.translateByTransaction = ve.dm.NullSelection.prototype.self;
78
79 ve.dm.NullSelection.prototype.translateByTransactionWithAuthor = ve.dm.NullSelection.prototype.self;
80
81 /**
82 * @inheritdoc
83 */
84 ve.dm.NullSelection.prototype.getRanges = function () {
85 return [];
86 };
87
88 /**
89 * @inheritdoc
90 */
91 ve.dm.NullSelection.prototype.getCoveringRange = function () {
92 return null;
93 };
94
95 /**
96 * @inheritdoc
97 */
98 ve.dm.NullSelection.prototype.equals = function ( other ) {
99 return this === other || (
100 !!other &&
101 other.constructor === this.constructor
102 );
103 };
104
105 /**
106 * @inheritdoc
107 */
108 ve.dm.NullSelection.prototype.isNull = function () {
109 return true;
110 };
111
112 /* Registration */
113
114 ve.dm.selectionFactory.register( ve.dm.NullSelection );