mce-button.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*!
  2. * @source: here
  3. *
  4. * @licstart The following is the entire license notice for the
  5. * JavaScript code in this page.
  6. *
  7. * Copyleft 2016 Jorge Maldonado Ventura
  8. *
  9. * The JavaScript code in this page is free software: you can
  10. * redistribute it and/or modify it under the terms of the GNU
  11. * General Public License (GNU GPL) as published by the Free Software
  12. * Foundation, either version 3 of the License, or (at your option)
  13. * any later version. The code is distributed WITHOUT ANY WARRANTY;
  14. * without even the implied warranty of MERCHANTABILITY or FITNESS
  15. * FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
  16. *
  17. * As additional permission under GNU GPL version 3 section 7, you
  18. * may distribute non-source (e.g., minimized or compacted) forms of
  19. * that code without the copy of the GNU GPL normally required by
  20. * section 4, provided you include this license notice and a URL
  21. * through which recipients can access the Corresponding Source.
  22. *
  23. * @licend The above is the entire license notice
  24. * for the JavaScript code in this page.
  25. *
  26. */
  27. /**
  28. *
  29. */
  30. (function() {
  31. tinymce.PluginManager.add('librevideojs', function(editor, url) {
  32. var sh_tag = 'librevideojs_video';
  33. //add popup
  34. editor.addCommand('librevideojs_popup', function(ui, v) {
  35. //setup defaults
  36. var url = '';
  37. if (v.url)
  38. url = v.url;
  39. var poster = '';
  40. if (v.poster)
  41. poster = v.poster;
  42. var code = 'webm';
  43. if (v.code)
  44. code = v.code;
  45. var color = 'materialteal';
  46. if (v.color)
  47. code = v.color;
  48. var content = '';
  49. if (v.content)
  50. content = v.content;
  51. editor.windowManager.open( {
  52. title: 'LibreVideoJS - Inserción de vídeo',
  53. body: [
  54. {
  55. type: 'textbox',
  56. name: 'url',
  57. label: 'URL',
  58. value: url,
  59. tooltip: 'Inserta la URL del vídeo'
  60. },
  61. {
  62. type: 'textbox',
  63. name: 'poster',
  64. label: 'Poster',
  65. value: poster,
  66. tooltip: 'Escribe aquí la URL de la imagen que deseas que se visualice antes de reproducir el vídeo'
  67. },
  68. {
  69. type: 'listbox',
  70. name: 'code',
  71. label: 'Formato',
  72. value: code,
  73. 'values': [
  74. {text: 'webm', value: 'webm'},
  75. {text: 'ogv', value: 'ogg'},
  76. {text: 'mp4', value: 'mp4'}
  77. ],
  78. tooltip: 'Selecciona el formato del vídeo'
  79. },
  80. {
  81. type: 'listbox',
  82. name: 'color',
  83. label: 'Piel',
  84. value: color,
  85. 'values': [
  86. {text: 'mixblue', value: 'mixblue'},
  87. {text: 'mixgrey', value: 'mixgrey'},
  88. {text: 'mixpurple', value: 'mixpurple'},
  89. {text: 'mixred', value: 'mixred'},
  90. {text: 'mixteal', value: 'mixteal'},
  91. {text: 'mixyellow', value: 'mixyellow'},
  92. {text: 'materialblue', value: 'materialblue'},
  93. {text: 'materialgrey', value: 'materialgrey'},
  94. {text: 'materialpurple', value: 'materialpurple'},
  95. {text: 'materialred', value: 'materialred'},
  96. {text: 'materialteal', value: 'materialteal'},
  97. {text: 'materialyellow', value: 'materialyellow'},
  98. ],
  99. tooltip: 'Selecciona el color'
  100. },
  101. {
  102. type: 'textbox',
  103. name: 'content',
  104. label: 'Extra',
  105. value: content,
  106. multiline: true,
  107. minWidth: 300,
  108. minHeight: 100
  109. }
  110. ],
  111. onsubmit: function(e) {
  112. var shortcode_str = '[' + sh_tag;
  113. if (typeof e.data.url != 'undefined' && e.data.url.length)
  114. shortcode_str += ' url="' + e.data.url + '"';
  115. if (typeof e.data.poster != 'undefined' && e.data.poster.length)
  116. shortcode_str += ' poster="' + e.data.poster + '"';
  117. if (typeof e.data.code != 'undefined' && e.data.code.length)
  118. shortcode_str += ' code="' + e.data.code + '"';
  119. if (typeof e.data.color != 'undefined' && e.data.color.length)
  120. shortcode_str += ' skin="' + e.data.color + '"';
  121. //add panel content
  122. shortcode_str += ']' + e.data.content + '[/' + sh_tag + ']';
  123. //insert shortcode to tinymce
  124. editor.insertContent(shortcode_str);
  125. }
  126. });
  127. });
  128. editor.addButton('librevideojs', {
  129. icon: 'librevideojs',
  130. tooltip: 'LibreVideoJS',
  131. onclick: function() {
  132. editor.execCommand('librevideojs_popup', '', {
  133. url : '',
  134. poster: '',
  135. code: 'webm',
  136. color: '',
  137. content: '',
  138. });
  139. }
  140. });
  141. });
  142. })();