API Docs for: 1.0.0
Show:

File: Resources/public/js/alloyeditor/buttons/embed.js

  1. /*
  2. * Copyright (C) eZ Systems AS. All rights reserved.
  3. * For full copyright and license information view LICENSE file distributed with this source code.
  4. */
  5. // **NOTICE:**
  6. // THIS IS AN AUTO-GENERATED FILE
  7. // DO YOUR MODIFICATIONS IN THE CORRESPONDING .jsx FILE
  8. // AND REGENERATE IT WITH: grunt jsx
  9. // END OF NOTICE
  10. YUI.add('ez-alloyeditor-button-embed', function (Y) {
  11. "use strict";
  12.  
  13. var AlloyEditor = Y.eZ.AlloyEditor,
  14. React = Y.eZ.React,
  15. ButtonEmbed;
  16.  
  17. /**
  18. * The ButtonEmbed component represents a button to add an embed element.
  19. *
  20. * @uses AlloyEditor.ButtonCommand
  21. * @uses AlloyEditor.ButtonStateClasses
  22. * @uses eZ.AlloyEditorToolbarConfig.ButtonEmbedDiscoverContent
  23. *
  24. * @class eZ.AlloyEditor.ButtonEmbed
  25. */
  26. ButtonEmbed = React.createClass({displayName: "ButtonEmbed",
  27. mixins: [
  28. AlloyEditor.ButtonCommand,
  29. AlloyEditor.ButtonStateClasses,
  30. Y.eZ.AlloyEditorButton.WidgetButton,
  31. Y.eZ.AlloyEditorButton.ButtonEmbedDiscoverContent,
  32. ],
  33.  
  34. statics: {
  35. key: 'ezembed'
  36. },
  37.  
  38. getDefaultProps: function () {
  39. return {
  40. command: 'ezembed',
  41. modifiesSelection: true,
  42. udwTitle: 'Select a content to embed',
  43. udwContentDiscoveredMethod: '_addEmbed',
  44. };
  45. },
  46.  
  47. /**
  48. * Returns the UDW title to pick a Content to embed.
  49. *
  50. * @method _getUDWTitle
  51. * @protected
  52. * @return {String}
  53. */
  54. _getUDWTitle: function () {
  55. return Y.eZ.trans('select.a.content.to.embed', {}, 'onlineeditor');
  56. },
  57.  
  58. /**
  59. * Executes the command generated by the ezembed plugin and set the
  60. * correct value based on the choosen content.
  61. *
  62. * @method _addEmbed
  63. * @param {EventFacade} e the result of the choice in the UDW
  64. * @protected
  65. */
  66. _addEmbed: function (e) {
  67. var contentInfo = e.selection.contentInfo,
  68. widget;
  69.  
  70. this.execCommand();
  71. this._setContentInfo(contentInfo);
  72. widget = this._getWidget().setWidgetContent('');
  73. this._fireUpdatedEmbed(e.selection);
  74. widget.setFocused(true);
  75. },
  76.  
  77. render: function () {
  78. var css = "ae-button ez-ae-labeled-button" + this.getStateClasses();
  79.  
  80. return (
  81. React.createElement("button", {className: css, onClick: this._chooseContent, tabIndex: this.props.tabIndex},
  82. React.createElement("span", {className: "ez-ae-icon ez-ae-icon-embed ez-font-icon"}),
  83. React.createElement("p", {className: "ez-ae-label"}, Y.eZ.trans('embed', {}, 'onlineeditor'))
  84. )
  85. );
  86. },
  87. });
  88.  
  89. AlloyEditor.Buttons[ButtonEmbed.key] = AlloyEditor.ButtonEmbed = ButtonEmbed;
  90. });
  91.