Projet

Général

Profil

Paste
Télécharger (4,65 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / ckeditor / includes / ckeditor.admin.js @ 2e0f6994

1
/*
2
Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
3
For licensing, see LICENSE.html or http://ckeditor.com/license
4
*/
5
(function ($) {
6
  Drupal.ckeditor_ver = 4;
7

    
8
  $(document).ready(function() {
9
    if (typeof(CKEDITOR) == "undefined")
10
      return;
11

    
12
    // $('#edit-uicolor-textarea').show();
13

    
14
    if (Drupal.settings.ckeditor_version) {
15
      Drupal.ckeditor_ver = Drupal.settings.ckeditor_version.split('.')[0];
16
    }
17

    
18
    Drupal.editSkinEditorInit = function() {
19
      var skinframe_src = $('#skinframe').attr('src');
20
      //skinframe_src = skinframe_src.replace(/skin=[^&]+/, 'skin='+$("#edit-skin").val());
21
      var skin = skinframe_src.match(/skin=([^&]+)/)[1];
22
      if ($('#edit-uicolor').val() == 'custom') {
23
        skinframe_src = skinframe_src.replace(/uicolor=[^&]+/, 'uicolor='+$('input[name$="uicolor_user"]').val().replace('#', '') || 'D3D3D3');
24
      }
25
      else {
26
        skinframe_src = skinframe_src.replace(/uicolor=[^&]+/, 'uicolor=D3D3D3');
27
      }
28
      $('#skinframe').attr('src', skinframe_src);
29

    
30
      if (Drupal.ckeditor_ver == 3) {
31
        if (skin == "kama") {
32
          $("#edit-uicolor").removeAttr('disabled');
33
          $("#edit-uicolor").parent().removeClass('form-disabled');
34
        }
35
        else {
36
          $("#edit-uicolor").attr('disabled', 'disabled');
37
          $("#edit-uicolor").parent().addClass('form-disabled');
38
        }
39
      }
40
      else {
41
        $("#edit-uicolor").removeAttr('disabled');
42
        $("#edit-uicolor").parent().removeClass('form-disabled');
43
      }
44
    };
45

    
46
    Drupal.editSkinEditorInit();
47

    
48
    $("#edit-uicolor").bind("change", function() {
49
      Drupal.editSkinEditorInit();
50
    });
51

    
52
    $("#input-formats :checkbox").change(function() {
53
      $('#security-filters .filter-warning').hide();
54
      $('#security-filters div.filter-text-formats[filter]').html('');
55
      $('#security-filters ul.text-formats-config').html('');
56
      $('#input-formats :checked').each(function() {
57
        var format_name = $(this).val();
58
        var format_label = $('label[for="' + $(this).attr('id') + '"]').html();
59

    
60
        if (typeof(Drupal.settings.text_formats_config_links[format_name]) != 'undefined') {
61
          var text = "<li>" + format_label + " - <a href=\"" + Drupal.settings.text_formats_config_links[format_name].config_url + "\">configure</a></li>";
62
          var dataSel = $('#security-filters ul.text-formats-config');
63
          var html = dataSel.html();
64
          if (html == null || html.length == 0) {
65
            dataSel.html(text);
66
          }
67
          else {
68
            html += text;
69
            dataSel.html(html);
70
          }
71
        }
72

    
73
        $('#security-filters div.filter-text-formats[filter]').each(function() {
74
          var filter_name = $(this).attr('filter');
75
          var dataSel = $(this);
76
          var html = dataSel.html();
77
          var status = "enabled";
78
          if (typeof Drupal.settings.text_format_filters[format_name][filter_name] == 'undefined') {
79
            status = "disabled";
80
          }
81
          var text = "<span class=\"filter-text-format-status " + status + "\">" + format_label + ': </span><br/>';
82

    
83
          if (html == null || html.length == 0) {
84
            dataSel.html(text);
85
          }
86
          else {
87
            html += text;
88
            dataSel.html(html);
89
          }
90
        });
91
      });
92
    });
93
    $("#input-formats :checkbox:eq(0)").trigger('change');
94

    
95
    $(".cke_load_toolbar", "#ckeditor-admin-profile-form").click(function() {
96
      var id = $(this).attr("id").replace(/[^\w]/g, '');
97
      if (typeof(Drupal.settings[id]) == 'undefined') {
98
        return false;
99
      }
100
      var buttons = Drupal.settings[id];
101
      var text = "[\n";
102
      for(i in buttons) {
103
        if (typeof buttons[i] == 'string'){
104
          text = text + "    '/',\n";
105
        }
106
        else {
107
          text = text + "    [";
108
          max = buttons[i].length - 1;
109
          rows = buttons.length - 1;
110
          for (j in buttons[i]) {
111
            if (j < max){
112
              text = text + "'" + buttons[i][j] + "',";
113
            } else {
114
              text = text + "'" + buttons[i][j] + "'";
115
            }
116
          }
117
          if (i < rows){
118
            text = text + "],\n";
119
          } else {
120
            text = text + "]\n";
121
          }
122
        }
123
      }
124

    
125
      text = text + "]";
126
      text = text.replace(/\['\/'\]/g,"'/'");
127
      $("#edit-toolbar").val(text);
128
      if (Drupal.settings.ckeditor_toolbar_wizard == 't'){
129
        Drupal.ckeditorToolbarReload();
130
      }
131
      return false;
132
    });
133

    
134
    if (Drupal.settings.ckeditor_toolbar_wizard == 'f'){
135
      $("form#ckeditor-admin-profile-form textarea#edit-toolbar, form#ckeditor-admin-profile-form #edit-toolbar + .grippie").show();
136
    }
137
  });
138
})(jQuery);