Projet

Général

Profil

Paste
Télécharger (1,38 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / media_ckeditor / js / media_ckeditor.format_form.js @ 59ae487e

1
/**
2
 * @file
3
 * Overrides of some functions in media and media_wysiwyg javascript.
4
 */
5

    
6
(function ($) {
7

    
8
// Sanity check, because javascript errors are bad.
9
if (typeof Drupal.media === 'undefined' ||
10
    typeof Drupal.media.formatForm === 'undefined') {
11
  return;
12
}
13

    
14
/**
15
 * This overrides the function of the same name from media/modules/media_wysiwyg/js/media_wysiwyg.format_form.js
16
 * It provides an implementation of that function that knows how to extract content from CKEditor instances.
17
 */
18
Drupal.media.formatForm.getEditorContent = function(fieldKey) {
19
  if (typeof CKEDITOR !== 'undefined' && CKEDITOR.instances[fieldKey]) {
20
    return CKEDITOR.instances[fieldKey].getData();
21
  }
22
  else {
23
    // Default case => no CKEditor instance for this field.
24
    return null;
25
  }
26
};
27

    
28
/**
29
 * This overrides the function of the same name from media/modules/media_wysiwyg/js/media_wysiwyg.format_form.js
30
 * It provides an implementation of that function that escapes user input from
31
 * overridden fields on the format form.
32
 */
33
Drupal.media.formatForm.escapeFieldInput = function(input) {
34
  // We escape the input here, in a similar manner to what CKEditor's widget
35
  // system does. This helps to make the "tagmap" accurate when the content is
36
  // edited again in the future, and so CKEditor will recognize the token as a
37
  // widget that needs to be upcast.
38
  return $('<div>').text(input).html();
39
}
40

    
41
})(jQuery);