video_filter.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. var video_filter_dialog = {};
  2. (function ($) {
  3. video_filter_dialog = {
  4. insert : function() {
  5. var ed = tinyMCEPopup.editor, e;
  6. tinyMCEPopup.restoreSelection();
  7. tinyMCEPopup.execCommand("mceBeginUndoLevel");
  8. var file_url = $('#edit-file-url').val();
  9. // @Todo: validate width and hight is INTs?
  10. if (file_url == "") {
  11. // File url is empty, we have nothing to insert, close the window
  12. ed.execCommand('mceRepaint');
  13. tinyMCEPopup.execCommand("mceEndUndoLevel");
  14. tinyMCEPopup.close();
  15. }
  16. else {
  17. var str = '[video:' + file_url;
  18. // If field is present (ie. not unset by the admin theme) and if value is not empty: insert value.
  19. if (typeof $('#edit-width').val() != 'undefined' && $('#edit-width').val() !== '') {
  20. str += ' width:' + $('#edit-width').val();
  21. }
  22. if (typeof $('#edit-height').val() != 'undefined' && $('#edit-height').val() !== '') {
  23. str += ' height:' + $('#edit-height').val();
  24. }
  25. if (typeof $('#edit-align').val() != 'undefined' && $('#edit-align').val() !== 'none') {
  26. str += ' align:' + $('#edit-align').val();
  27. }
  28. if ($('#edit-autoplay').is(':checked')) {
  29. str += ' autoplay:' + $('#edit-autoplay').val();
  30. }
  31. else {
  32. str += ' autoplay:' + '0';
  33. }
  34. str += ']';
  35. ed.execCommand('mceInsertContent', false, str);
  36. }
  37. tinyMCEPopup.execCommand("mceEndUndoLevel");
  38. tinyMCEPopup.close();
  39. }
  40. };
  41. Drupal.behaviors.video_filter_tinymce = {
  42. attach: function(context, settings) {
  43. $('#edit-insert').click(function() {
  44. video_filter_dialog.insert();
  45. });
  46. $('#edit-cancel').click(function() {
  47. tinyMCEPopup.close();
  48. });
  49. }
  50. }
  51. })(jQuery);