panelposition.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. import Model from '../../../src/model';
  6. import Collection from '@ckeditor/ckeditor5-utils/src/collection';
  7. import testUtils from '../../_utils/utils';
  8. import { createDropdown, addListToDropdown } from '../../../src/dropdown/utils';
  9. const ui = testUtils.createTestUIView( {
  10. dropdownNW: '#dropdown-nw',
  11. dropdownNE: '#dropdown-ne',
  12. dropdownSE: '#dropdown-se',
  13. dropdownSW: '#dropdown-sw'
  14. } );
  15. function createPositionedDropdown( position ) {
  16. const collection = new Collection( { idProperty: 'label' } );
  17. [
  18. 'long label of a first item of the list',
  19. 'long label of a second item of the list',
  20. 'long label of a third item of the list'
  21. ].forEach( label => {
  22. collection.add( {
  23. type: 'button',
  24. model: new Model( { label, withText: true } )
  25. } );
  26. } );
  27. const dropdownView = createDropdown( {} );
  28. dropdownView.buttonView.set( {
  29. label: `Dropdown ${ position }`,
  30. isEnabled: true,
  31. isOn: false,
  32. withText: true
  33. } );
  34. addListToDropdown( dropdownView, collection );
  35. ui[ `dropdown${ position }` ].add( dropdownView );
  36. }
  37. createPositionedDropdown( 'NW' );
  38. createPositionedDropdown( 'NE' );
  39. createPositionedDropdown( 'SW' );
  40. createPositionedDropdown( 'SE' );