Projet

Général

Profil

Révision 6fd71452

Ajouté par Julien Enselme il y a environ 10 ans

Update CKEditor

Voir les différences:

drupal7/sites/all/modules/ckeditor/includes/ckeditor.utils.js
2 2
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3 3
For licensing, see LICENSE.html or http://ckeditor.com/license
4 4
*/
5
window.CKEDITOR_BASEPATH = Drupal.settings.ckeditor.editor_path;
5
if (typeof window.CKEDITOR_BASEPATH === 'undefined') {
6
  window.CKEDITOR_BASEPATH = Drupal.settings.ckeditor.editor_path;
7
}
6 8
(function ($) {
7 9
  Drupal.ckeditor = (typeof(CKEDITOR) != 'undefined');
8 10
  Drupal.ckeditor_ver = false;
......
15 17
    for (i=0; i<textarea_ids.length; i++){
16 18
      if (typeof(CKEDITOR.instances) != 'undefined' && typeof(CKEDITOR.instances[textarea_ids[i]]) != 'undefined'){
17 19
        Drupal.ckeditorOff(textarea_ids[i]);
18
        $('#switch_' + textarea_ids[0]).text(TextRTE);
20
        $('#switch_' + textarea_ids[i]).text(TextRTE);
19 21
      }
20 22
      else {
21 23
        Drupal.ckeditorOn(textarea_ids[i]);
22
        $('#switch_' + textarea_ids[0]).text(TextTextarea);
24
        $('#switch_' + textarea_ids[i]).text(TextTextarea);
23 25
      }
24 26
    }
25 27
  };
......
276 278
    }
277 279
  };
278 280

  
279
  /**
280
 * Drupal behaviors
281
 */
282
  Drupal.behaviors.ckeditor = {
283
    attach:
284
    function (context) {
285
      if ((typeof(CKEDITOR) == 'undefined') || !CKEDITOR.env.isCompatible) {
286
        return;
287
      }
281
  function attachCKEditor(context) {
282
    // make sure the textarea behavior is run first, to get a correctly sized grippie
283
    if (Drupal.behaviors.textarea && Drupal.behaviors.textarea.attach) {
284
      Drupal.behaviors.textarea.attach(context);
285
    }
288 286

  
289
      // make sure the textarea behavior is run first, to get a correctly sized grippie
290
      if (Drupal.behaviors.textarea && Drupal.behaviors.textarea.attach) {
291
        Drupal.behaviors.textarea.attach(context);
287
    $(context).find("textarea.ckeditor-mod:not(.ckeditor-processed)").each(function () {
288
      var ta_id=$(this).attr("id");
289
      if (CKEDITOR.instances && typeof(CKEDITOR.instances[ta_id]) != 'undefined'){
290
        Drupal.ckeditorOff(ta_id);
292 291
      }
293 292

  
294
      $(context).find("textarea.ckeditor-mod:not(.ckeditor-processed)").each(function () {
295
        var ta_id=$(this).attr("id");
296
        if (CKEDITOR.instances && typeof(CKEDITOR.instances[ta_id]) != 'undefined'){
297
          Drupal.ckeditorOff(ta_id);
298
        }
299

  
300
        if ((typeof(Drupal.settings.ckeditor.autostart) != 'undefined') && (typeof(Drupal.settings.ckeditor.autostart[ta_id]) != 'undefined')) {
301
          Drupal.ckeditorOn(ta_id);
302
        }
293
      if ((typeof(Drupal.settings.ckeditor.autostart) != 'undefined') && (typeof(Drupal.settings.ckeditor.autostart[ta_id]) != 'undefined')) {
294
        Drupal.ckeditorOn(ta_id);
295
      }
303 296

  
304
        if (typeof(Drupal.settings.ckeditor.input_formats[Drupal.settings.ckeditor.elements[ta_id]]) != 'undefined') {
305
          $('.ckeditor_links').show();
306
        }
297
      if (typeof(Drupal.settings.ckeditor.input_formats[Drupal.settings.ckeditor.elements[ta_id]]) != 'undefined') {
298
        $('.ckeditor_links').show();
299
      }
307 300

  
308
        var sel_format = $("#" + ta_id.substr(0, ta_id.lastIndexOf("-")) + "-format--2");
309
        if (sel_format && sel_format.not('.ckeditor-processed')) {
310
          sel_format.addClass('ckeditor-processed').change(function() {
311
            Drupal.settings.ckeditor.elements[ta_id] = $(this).val();
312
            if (CKEDITOR.instances && typeof(CKEDITOR.instances[ta_id]) != 'undefined') {
313
              $('#'+ta_id).val(CKEDITOR.instances[ta_id].getData());
314
            }
315
            Drupal.ckeditorOff(ta_id);
316
            if (typeof(Drupal.settings.ckeditor.input_formats[$(this).val()]) != 'undefined'){
317
              if ($('#'+ta_id).hasClass('ckeditor-processed')) {
318
                Drupal.ckeditorOn(ta_id, false);
319
              }
320
              else {
321
                Drupal.ckeditorOn(ta_id);
322
              }
323
              $('#switch_'+ta_id).show();
301
      var sel_format = $("#" + ta_id.substr(0, ta_id.lastIndexOf("-")) + "-format--2");
302
      if (sel_format && sel_format.not('.ckeditor-processed')) {
303
        sel_format.addClass('ckeditor-processed').change(function() {
304
          Drupal.settings.ckeditor.elements[ta_id] = $(this).val();
305
          if (CKEDITOR.instances && typeof(CKEDITOR.instances[ta_id]) != 'undefined') {
306
            $('#'+ta_id).val(CKEDITOR.instances[ta_id].getData());
307
          }
308
          Drupal.ckeditorOff(ta_id);
309
          if (typeof(Drupal.settings.ckeditor.input_formats[$(this).val()]) != 'undefined'){
310
            if ($('#'+ta_id).hasClass('ckeditor-processed')) {
311
              Drupal.ckeditorOn(ta_id, false);
324 312
            }
325 313
            else {
326
              $('#switch_'+ta_id).hide();
314
              Drupal.ckeditorOn(ta_id);
327 315
            }
328
          });
316
            $('#switch_'+ta_id).show();
317
          }
318
          else {
319
            $('#switch_'+ta_id).hide();
320
          }
321
        });
322
      }
323
    });
324
  }
325

  
326
  /**
327
 * Drupal behaviors
328
 */
329
  Drupal.behaviors.ckeditor = {
330
    attach:
331
    function (context) {
332
      // If CKEDITOR is undefined and script is loaded from CDN, wait up to 15 seconds until it loads [#2244817]
333
      if ((typeof(CKEDITOR) == 'undefined') && Drupal.settings.ckeditor.editor_path.match(/^(http(s)?:)?\/\//i)) {
334
        if (typeof(Drupal.settings.ckeditor.loadAttempts) == 'undefined') {
335
          Drupal.settings.ckeditor.loadAttempts = 50;
329 336
        }
330
      });
337
        if (Drupal.settings.ckeditor.loadAttempts > 0) {
338
          Drupal.settings.ckeditor.loadAttempts--;
339
          window.setTimeout(function() {
340
            Drupal.behaviors.ckeditor.attach(context);
341
          }, 300);
342
        }
343
        return;
344
      }
345
      if ((typeof(CKEDITOR) == 'undefined') || !CKEDITOR.env.isCompatible) {
346
        return;
347
      }
348
      attachCKEditor(context);
331 349
    },
332 350
    detach:
333 351
    function(context, settings, trigger){
......
342 360
      });
343 361
    }
344 362
  };
363

  
364
  // Support CTools detach event.
365
  $(document).bind('CToolsDetachBehaviors', function(event, context) {
366
    Drupal.behaviors.ckeditor.detach(context, {}, 'unload');
367
  });
345 368
})(jQuery);
346 369

  
347 370
/**
......
359 382
  CKEDITOR.tools.callFunction(cfunc[1], file.url);
360 383
  win.close();
361 384
}
385

  

Formats disponibles : Unified diff