Debian Codegraph @

extensions/VisualEditor/lib/ve/src/ui/tools/ve.ui.ListTool.js

raw symbols SCIP
1 /*!
2 * VisualEditor UserInterface ListTool classes.
3 *
4 * @copyright See AUTHORS.txt
5 */
6
7 /**
8 * UserInterface list tool.
9 *
10 * @abstract
11 * @class
12 * @extends ve.ui.Tool
13 * @constructor
14 * @param {OO.ui.ToolGroup} toolGroup
15 * @param {Object} [config] Configuration options
16 */
17 ve.ui.ListTool = function VeUiListTool() {
18 // Parent constructor
19 ve.ui.ListTool.super.apply( this, arguments );
20
21 // Properties
22 this.method = null;
23 };
24
25 /* Inheritance */
26
27 OO.inheritClass( ve.ui.ListTool, ve.ui.Tool );
28
29 /* Static Properties */
30
31 /**
32 * List style the tool applies.
33 *
34 * @abstract
35 * @static
36 * @property {string}
37 * @inheritable
38 */
39 ve.ui.ListTool.static.style = '';
40
41 ve.ui.ListTool.static.deactivateOnSelect = false;
42
43 /* Methods */
44
45 /**
46 * @inheritdoc
47 */
48 ve.ui.ListTool.prototype.onUpdateState = function ( fragment ) {
49 // Parent method
50 ve.ui.ListTool.super.prototype.onUpdateState.apply( this, arguments );
51
52 const style = this.constructor.static.style;
53 const isMatching = fragment.hasMatchingAncestor( 'list', { style: style }, true );
54 this.setActive( isMatching );
55 };
56
57 /**
58 * UserInterface bullet tool.
59 *
60 * @class
61 * @extends ve.ui.ListTool
62 * @constructor
63 * @param {OO.ui.ToolGroup} toolGroup
64 * @param {Object} [config] Configuration options
65 */
66 ve.ui.BulletListTool = function VeUiBulletListTool() {
67 ve.ui.BulletListTool.super.apply( this, arguments );
68 };
69 OO.inheritClass( ve.ui.BulletListTool, ve.ui.ListTool );
70 ve.ui.BulletListTool.static.name = 'bullet';
71 ve.ui.BulletListTool.static.group = 'structure';
72 ve.ui.BulletListTool.static.icon = 'listBullet';
73 ve.ui.BulletListTool.static.title =
74 OO.ui.deferMsg( 'visualeditor-listbutton-bullet-tooltip' );
75 ve.ui.BulletListTool.static.style = 'bullet';
76 ve.ui.BulletListTool.static.commandName = 'bullet';
77 ve.ui.toolFactory.register( ve.ui.BulletListTool );
78
79 /**
80 * UserInterface number tool.
81 *
82 * @class
83 * @extends ve.ui.ListTool
84 * @constructor
85 * @param {OO.ui.ToolGroup} toolGroup
86 * @param {Object} [config] Configuration options
87 */
88 ve.ui.NumberListTool = function VeUiNumberListTool() {
89 ve.ui.NumberListTool.super.apply( this, arguments );
90 };
91 OO.inheritClass( ve.ui.NumberListTool, ve.ui.ListTool );
92 ve.ui.NumberListTool.static.name = 'number';
93 ve.ui.NumberListTool.static.group = 'structure';
94 ve.ui.NumberListTool.static.icon = 'listNumbered';
95 ve.ui.NumberListTool.static.title =
96 OO.ui.deferMsg( 'visualeditor-listbutton-number-tooltip' );
97 ve.ui.NumberListTool.static.style = 'number';
98 ve.ui.NumberListTool.static.commandName = 'number';
99 ve.ui.toolFactory.register( ve.ui.NumberListTool );