button.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. 'use strict';
  6. import Controller from '../controller.js';
  7. /**
  8. * The basic button controller class.
  9. *
  10. * @memberOf core.ui.button
  11. * @extends core.ui.Controller
  12. */
  13. export default class Button extends Controller {
  14. constructor( model, view ) {
  15. super( model, view );
  16. view.on( 'click', () => model.fire( 'execute' ) );
  17. }
  18. }
  19. /**
  20. * The basic button model interface.
  21. *
  22. * @memberOf core.ui.button
  23. * @interface ButtonModel
  24. */
  25. /**
  26. * The label of the button.
  27. *
  28. * @member {String} core.ui.button.ButtonModel#label
  29. */
  30. /**
  31. * Whether the button is "on" (e.g. some feature which this button represents is currently enabled).
  32. *
  33. * @member {Boolean} core.ui.button.ButtonModel#isOn
  34. */
  35. /**
  36. * Whether the button is enabled (can be clicked).
  37. *
  38. * @member {Boolean} core.ui.button.ButtonModel#isEnabled
  39. */
  40. /**
  41. * Fired when the button action should be executed.
  42. *
  43. * @event core.ui.button.ButtonModel#execute
  44. */