Debian Codegraph @

extensions/VisualEditor/lib/ve/src/ui/layouts/ve.ui.SymbolListBookletLayout.js

raw symbols SCIP
1 /*!
2 * VisualEditor UserInterface SymbolListBookletLayout class.
3 *
4 * @copyright See AUTHORS.txt
5 */
6
7 /**
8 * ...
9 *
10 * @class
11 * @extends OO.ui.BookletLayout
12 *
13 * @constructor
14 * @param {Object} [config] Configuration options
15 */
16 ve.ui.SymbolListBookletLayout = function VeUiSymbolListBookletLayout( config ) {
17 config = config || {};
18
19 // Parent constructor
20 ve.ui.SymbolListBookletLayout.super.call( this, ve.extendObject( {
21 outlined: true,
22 continuous: true
23 }, config ) );
24
25 this.$element.addClass( 've-ui-symbolListBookletLayout' );
26 };
27
28 /* Inheritance */
29
30 OO.inheritClass( ve.ui.SymbolListBookletLayout, OO.ui.BookletLayout );
31
32 /* Methods */
33
34 /**
35 * Set symbol data
36 *
37 * @param {Object} symbolData
38 */
39 ve.ui.SymbolListBookletLayout.prototype.setSymbolData = function ( symbolData ) {
40 const pages = [];
41 for ( const category in symbolData ) {
42 pages.push(
43 new ve.ui.SymbolListPage( category, symbolData[ category ] )
44 );
45 }
46 this.addPages( pages );
47 this.$element.on(
48 'click',
49 '.ve-ui-symbolListPage-symbol',
50 this.onListClick.bind( this )
51 );
52 };
53
54 /**
55 * Handle the click event on the list
56 *
57 * @param {jQuery.Event} e Mouse click event
58 */
59 ve.ui.SymbolListBookletLayout.prototype.onListClick = function ( e ) {
60 const symbol = $( e.target ).data( 'symbol' );
61
62 if ( symbol ) {
63 this.emit( 'choose', symbol );
64 }
65 };