Projet

Général

Profil

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

root / drupal7 / sites / all / modules / ckeditor / includes / ckeditor.admin.js @ 5a7e6170

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 = false;
7

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

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

    
14
    Drupal.ckeditor_ver = Drupal.settings.ckeditor_version.split('.')[0];
15

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

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

    
44
    Drupal.editSkinEditorInit();
45

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

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

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

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

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

    
93
    $(".cke_load_toolbar").click(function() {
94
      var buttons = eval('Drupal.settings.'+$(this).attr("id"));
95
      var text = "[\n";
96
      for(i in buttons) {
97
        if (typeof buttons[i] == 'string'){
98
          text = text + "    '/',\n";
99
        }
100
        else {
101
          text = text + "    [";
102
          max = buttons[i].length - 1;
103
          rows = buttons.length - 1;
104
          for (j in buttons[i]) {
105
            if (j < max){
106
              text = text + "'" + buttons[i][j] + "',";
107
            } else {
108
              text = text + "'" + buttons[i][j] + "'";
109
            }
110
          }
111
          if (i < rows){
112
            text = text + "],\n";
113
          } else {
114
            text = text + "]\n";
115
          }
116
        }
117
      }
118

    
119
      text = text + "]";
120
      text = text.replace(/\['\/'\]/g,"'/'");
121
      $("#edit-toolbar").attr('value',text);
122
      if (Drupal.settings.ckeditor_toolbar_wizard == 't'){
123
        Drupal.ckeditorToolbarReload();
124
      }
125
      return false;
126
    });
127

    
128
    if (Drupal.settings.ckeditor_toolbar_wizard == 'f'){
129
      $("form#ckeditor-admin-profile-form textarea#edit-toolbar, form#ckeditor-admin-profile-form #edit-toolbar + .grippie").show();
130
    }
131
  });
132
})(jQuery);