Skip to content

Instantly share code, notes, and snippets.

@bigeasy
Created August 24, 2009 18:28
Show Gist options
  • Save bigeasy/174019 to your computer and use it in GitHub Desktop.
Save bigeasy/174019 to your computer and use it in GitHub Desktop.
How to use Scott Rutherford's FCKEditor Plugin with Adva CMS.
// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
applyOrRemoveFCKeditors = function() {
$('textarea.wysiwyg').each(function() {
var id = $(this).attr('id');
var filter = $('select.columnsFilter')[0];
// Transform all textareas to FCKeditors, but only if filter is set to plain
// HTML or no filter is defined.
if (typeof filter == 'undefined' || $(filter).val() == '') {
height = $(this).height();
if (height == 0) height = 200; // default height = 200px
FCKeditor.BasePath = '/javascripts/fckeditor/'
var fckeditor = new FCKeditor(id);
fckeditor.Config['CustomConfigurationsPath'] = '/javascripts/fckeditor_config.js';
fckeditor.Width = '100%';
fckeditor.Height = height;
fckeditor.ToolbarSet = 'Semantic';
fckeditor.ReplaceTextarea();
} else {
var frame = $('#' + id + '___Frame');
if (frame) $(frame).remove();
var config = $('#' + id + '___Config');
if (config) $(config).remove();
$(this).show();
}
});
}
$(document).ready(function() {
applyOrRemoveFCKeditors();
$('select.columnsFilter').change(function() {
applyOrRemoveFCKeditors();
});
});
ActionView::Helpers::AssetTagHelper.register_javascript_expansion :admin => %w[fckeditor/fckeditor.js]
// CHANGE FOR APPS HOSTED IN SUBDIRECTORY
FCKRelativePath = '';
FCKConfig.BasePath = '/javascripts/fckeditor/editor/'
var server = (location.port != 80) ? 'http://' + location.hostname + ':' + location.port : '';
// DON'T CHANGE THESE
FCKConfig.LinkBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Connector='+FCKRelativePath+'/fckeditor/command';
FCKConfig.ImageBrowserURL = server + FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Type=Image&Connector='+FCKRelativePath+'/fckeditor/command';
FCKConfig.FlashBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Type=Flash&Connector='+FCKRelativePath+'/fckeditor/command';
FCKConfig.LinkUploadURL = FCKRelativePath+'/fckeditor/upload';
FCKConfig.ImageUploadURL = FCKRelativePath+'/fckeditor/upload?Type=Image';
FCKConfig.FlashUploadURL = FCKRelativePath+'/fckeditor/upload?Type=Flash';
FCKConfig.SpellerPagesServerScript = FCKRelativePath+'/fckeditor/check_spelling';
FCKConfig.AllowQueryStringDebug = false;
FCKConfig.SpellChecker = 'SpellerPages';
// ONLY CHANGE BELOW HERE
FCKConfig.SkinPath = FCKConfig.BasePath + 'skins/silver/';
FCKConfig.ToolbarSets = FCKConfig.ToolbarSets || {};
FCKConfig.ToolbarSets["Semantic"] = [
['Source','-','-','Templates'],
['Cut','Copy','Paste','PasteWord','-','Print','SpellCheck'],
['Undo','Redo','-','Find','Replace','-','SelectAll'],
'/',
['Image','Flash','Table','Rule','Smiley','SpecialChar','PageBreak'],
'/',
['FontFormat'], ['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript']
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment