video_filter.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. str += ']';
  32. ed.execCommand('mceInsertContent', false, str);
  33. }
  34. tinyMCEPopup.execCommand("mceEndUndoLevel");
  35. tinyMCEPopup.close();
  36. }
  37. };
  38. Drupal.behaviors.video_filter_tinymce = {
  39. attach: function(context, settings) {
  40. $('#edit-insert').click(function() {
  41. video_filter_dialog.insert();
  42. });
  43. $('#edit-cancel').click(function() {
  44. tinyMCEPopup.close();
  45. });
  46. }
  47. }
  48. })(jQuery);