Skip to content

Commit

Permalink
swap out ckeditor for ckeditor_rails
Browse files Browse the repository at this point in the history
  • Loading branch information
acesuares committed Jul 12, 2015
1 parent 5cbbaad commit bf8b174
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 31 deletions.
11 changes: 1 addition & 10 deletions bin/inline_forms_installer_core.rb
Expand Up @@ -11,7 +11,7 @@
gem 'capistrano'
gem 'will_paginate', :git => 'git://github.com/acesuares/will_paginate.git'
gem 'tabs_on_rails', :git => 'git://github.com/acesuares/tabs_on_rails.git', :branch => 'update_remote'
gem 'ckeditor'
gem 'ckeditor_rails'
gem 'cancan', :git => 'git://github.com/acesuares/cancan.git', :branch => '2.0'
gem 'carrierwave'
gem 'remotipart', '~> 1.0'
Expand Down Expand Up @@ -288,15 +288,6 @@ def self.down
copy_file File.join(GENERATOR_PATH, 'lib/generators/assets/javascripts' , javascript), File.join('app/assets/javascripts' , javascript)
end

say "- Install ckeditor..."
generate "ckeditor:install --orm=active_record --backend=carrierwave"

say "- Mount Ckeditor::Engine to routes..."
route "mount Ckeditor::Engine => '/ckeditor'"

say "- Add ckeditor autoload_paths to application.rb..."
application "config.autoload_paths += %W(\#{config.root}/app/models/ckeditor)"

say "- Create ckeditor config.js"
copy_file File.join(GENERATOR_PATH, 'lib/generators/assets/javascripts/ckeditor/config.js'), "app/assets/javascripts/ckeditor/config.js"

Expand Down
31 changes: 12 additions & 19 deletions lib/app/helpers/form_elements/ckeditor.rb
Expand Up @@ -2,37 +2,30 @@
InlineForms::SPECIAL_COLUMN_TYPES[:ckeditor]=:text

def ckeditor_show(object, attribute)
# "</div><script>$('#".html_safe +
# "textarea_#{object.class.name.underscore}_#{object.id}_#{attribute.to_s}" + "').ckeditor();</script>".html_safe

link_to_inline_edit object,
attribute,
'<div class="ckeditor_area">'.html_safe +
cktext_area_tag(
attribute,
object[attribute],
:id => "textarea_#{object.class.name.underscore}_#{object.id}_#{attribute.to_s}",
:ckeditor => { :width => '100%',
:height => '200px',
:toolbar => "None",
:readOnly => "true",
:resize_enabled => "false",
:toolbarCanCollapse => "false"
}
) +
text_area_tag( attribute,
object[attribute],
:id => "textarea_#{object.class.name.underscore}_#{object.id}_#{attribute.to_s}",
) +
image_tag( 'glass_plate.gif',
:class => "glass_plate",
:title => '' ) +
"<script>delete CKEDITOR.instances['textarea_#{object.class.name.underscore}_#{object.id}_#{attribute.to_s}']</script>".html_safe +
'</div>'.html_safe
"</div><script>$('#".html_safe +
"textarea_#{object.class.name.underscore}_#{object.id}_#{attribute.to_s}" + "').ckeditor();</script>".html_safe
end

def ckeditor_edit(object, attribute)
cktext_area_tag( attribute,
text_area_tag( attribute,
object[attribute],
:id => "textarea_#{object.class.name.underscore}_#{object.id}_#{attribute.to_s}",
:ckeditor => { :width => '100%',
:height => '200px'
}
) +
"<script>delete CKEDITOR.instances['textarea_#{object.class.name.underscore}_#{object.id}_#{attribute.to_s}']</script>".html_safe
"<script>$('#".html_safe +
"textarea_#{object.class.name.underscore}_#{object.id}_#{attribute.to_s}" + "').ckeditor();</script>".html_safe
end

def ckeditor_update(object, attribute)
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/assets/javascripts/application.js
Expand Up @@ -12,8 +12,8 @@
//
//= require jquery
//= require jquery_ujs
//= require ckeditor-jquery
//= require jquery.ui.all
//= require ckeditor/init
//= require foundation
//= require jquery.remotipart
//= require inline_forms
7 changes: 7 additions & 0 deletions lib/generators/locales/inline_forms_local.en.yml
@@ -0,0 +1,7 @@
en:
inline_forms:
general:
application_title: MyApp
devise:
title_for_devise: MyApp
welcome: Welcome to MyApp!
2 changes: 1 addition & 1 deletion lib/inline_forms/version.rb
@@ -1,4 +1,4 @@
# -*- encoding : utf-8 -*-
module InlineForms
VERSION = "3.0.57"
VERSION = "3.0.58"
end

0 comments on commit bf8b174

Please sign in to comment.