ButtonGroup.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * ButtonGroup.js
  3. *
  4. * Copyright, Moxiecode Systems AB
  5. * Released under LGPL License.
  6. *
  7. * License: http://www.tinymce.com/license
  8. * Contributing: http://www.tinymce.com/contributing
  9. */
  10. /**
  11. * This control enables you to put multiple buttons into a group. This is
  12. * useful when you want to combine similar toolbar buttons into a group.
  13. *
  14. * @example
  15. * // Create and render a buttongroup with two buttons to the body element
  16. * tinymce.ui.Factory.create({
  17. * type: 'buttongroup',
  18. * items: [
  19. * {text: 'Button A'},
  20. * {text: 'Button B'}
  21. * ]
  22. * }).renderTo(document.body);
  23. *
  24. * @-x-less ButtonGroup.less
  25. * @class tinymce.ui.ButtonGroup
  26. * @extends tinymce.ui.Container
  27. */
  28. define("tinymce/ui/ButtonGroup", [
  29. "tinymce/ui/Container"
  30. ], function(Container) {
  31. "use strict";
  32. return Container.extend({
  33. Defaults: {
  34. defaultType: 'button',
  35. role: 'group'
  36. },
  37. /**
  38. * Renders the control as a HTML string.
  39. *
  40. * @method renderHtml
  41. * @return {String} HTML representing the control.
  42. */
  43. renderHtml: function() {
  44. var self = this, layout = self._layout;
  45. self.addClass('btn-group');
  46. self.preRender();
  47. layout.preRender(self);
  48. return (
  49. '<div id="' + self._id + '" class="' + self.classes() + '">' +
  50. '<div id="' + self._id + '-body">' +
  51. (self.settings.html || '') + layout.renderHtml(self) +
  52. '</div>' +
  53. '</div>'
  54. );
  55. }
  56. });
  57. });