8
0

labelview.js 942 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /**
  6. * @module ui/label/labelview
  7. */
  8. import View from '../view';
  9. import '../../theme/components/label/label.css';
  10. /**
  11. * The label view class.
  12. *
  13. * @extends module:ui/view~View
  14. */
  15. export default class LabelView extends View {
  16. /**
  17. * @inheritDoc
  18. */
  19. constructor( locale ) {
  20. super( locale );
  21. /**
  22. * The text of the label.
  23. *
  24. * @observable
  25. * @member {String} #text
  26. */
  27. this.set( 'text' );
  28. /**
  29. * The `for` attribute of the label (i.e. to pair with an `<input>` element).
  30. *
  31. * @observable
  32. * @member {String} #for
  33. */
  34. this.set( 'for' );
  35. const bind = this.bindTemplate;
  36. this.setTemplate( {
  37. tag: 'label',
  38. attributes: {
  39. class: [
  40. 'ck-label'
  41. ],
  42. for: bind.to( 'for' )
  43. },
  44. children: [
  45. {
  46. text: bind.to( 'text' )
  47. }
  48. ]
  49. } );
  50. }
  51. }