mardi 30 juin 2015

Editor not loading up sometimes

It just shows this with a tiny box:

<p><u><em><strong>Synopsis</strong></em></u></p>

<p><u><em><strong>

I suspect the page is slow and it just doesn't load. What do I do? When I say ckeditor doesn't load, I mean it doesn't provide any styles or edits or anything. It just shows a tiny box. I'll show it below. Any help would be appreciated

application.js

//= require ckeditor/init
//= require_self
//= require jquery
//= require jquery_ujs
//= require chosen-jquery
//= require turbolinks
//= require_tree .
//= require bootstrap-sprockets

ckeditor/config.js

  CKEDITOR.editorConfig = function( config )
  {
  /* Filebrowser routes */
  // The location of an external file browser, that should be launched when "Browse Server" button is pressed.


  // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Flash dialog.


  // The location of a script that handles file uploads in the Flash dialog.
  config.filebrowserFlashUploadUrl = "/ckeditor/attachment_files";

  // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Link tab of Image dialog.


  // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Image dialog.


  // The location of a script that handles file uploads in the Image dialog.
  config.filebrowserImageUploadUrl = "/ckeditor/pictures";

  // The location of a script that handles file uploads.
  config.filebrowserUploadUrl = "/ckeditor/attachment_files";

  // Rails CSRF token
  config.filebrowserParams = function(){
    var csrf_token, csrf_param, meta,
        metas = document.getElementsByTagName('meta'),
        params = new Object();

    for ( var i = 0 ; i < metas.length ; i++ ){
      meta = metas[i];

      switch(meta.name) {
        case "csrf-token":
          csrf_token = meta.content;
          break;
        case "csrf-param":
          csrf_param = meta.content;
          break;
        default:
          continue;
      }
    }

    if (csrf_param !== undefined && csrf_token !== undefined) {
      params[csrf_param] = csrf_token;
    }

    return params;
  };

  config.addQueryString = function( url, params ){
    var queryString = [];

    if ( !params ) {
      return url;
    } else {
      for ( var i in params )
        queryString.push( i + "=" + encodeURIComponent( params[ i ] ) );
    }

    return url + ( ( url.indexOf( "?" ) != -1 ) ? "&" : "?" ) + queryString.join( "&" );
  };

  // Integrate Rails CSRF token into file upload dialogs (link, image, attachment and flash)
  CKEDITOR.on( 'dialogDefinition', function( ev ){
    // Take the dialog name and its definition from the event data.
    var dialogName = ev.data.name;
    var dialogDefinition = ev.data.definition;
    var content, upload;

    if (CKEDITOR.tools.indexOf(['link', 'image', 'attachment', 'flash'], dialogName) > -1) {
      content = (dialogDefinition.getContents('Upload') || dialogDefinition.getContents('upload'));
      upload = (content == null ? null : content.get('upload'));

      if (upload && upload.filebrowser && upload.filebrowser['params'] === undefined) {
        upload.filebrowser['params'] = config.filebrowserParams();
        upload.action = config.addQueryString(upload.action, upload.filebrowser['params']);
      }
    }
  });

  config.toolbar =
    [
        [ 'Undo','Redo'],
        [ 'FontSize', 'Blockquote','-', '-', 'Bold', 'Italic', 'Underline', 'Subscript', 'Superscript', '-', 'RemoveFormat' ],
        [ 'NumberedList', 'BulletedList', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
        ['TextColor','BGColor', 'Maximize'],
        ['Image','Link','Unlink'],
        ['Find']
    ];

    config.enterMode = CKEDITOR.ENTER_P; // inserts <br />;
    config.language = 'en';

  config.htmlEncodeOutput = false;
  config.entities = false;

};

(function() {
  var isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
  if (isChrome) {
    CKEDITOR.on( 'instanceLoaded', function( e ){
      this.addCss('.cke_editable { line-height: normal; }');
    });
  }
})();

Aucun commentaire:

Enregistrer un commentaire