Projet

Général

Profil

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

root / drupal7 / sites / all / modules / media_ckeditor / js / media_ckeditor.format_form.js @ da542b7b

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, and is mostly a copy of, a function from the following file:
16
 * media/modules/media_wysiwyg/js/media_wysiwyg.format_form.js
17
 */
18
Drupal.media.formatForm.getOptions = function () {
19
  // Get all the values
20
  var ret = {};
21

    
22
  $.each($('#media-wysiwyg-format-form .fieldset-wrapper *').serializeArray(), function (i, field) {
23
    // For all fields, since they WILL be in JSON, encode them.
24
    ret[field.name] = encodeURIComponent(field.value);
25

    
26
    // When a field uses a WYSIWYG format, the value needs to be extracted.
27
    if (field.name.match(/\[format\]/i)) {
28
      field.name = field.name.replace(/\[format\]/i, '[value]');
29
      field.key  = 'edit-' + field.name.replace(/[_\[]/g, '-').replace(/[\]]/g, '');
30

    
31
      if (typeof CKEDITOR !== 'undefined') {
32
        if (CKEDITOR.instances[field.key]) {
33
          ret[field.name] = CKEDITOR.instances[field.key].getData();
34
          ret[field.name] = encodeURIComponent(ret[field.name]);
35
        }
36
      }
37
    }
38
  });
39

    
40
  return ret;
41
};
42

    
43
})(jQuery);