Sha256: a7fe5d36df4f3311a46fd071f0f60f0409aa0af3e7b109fc26689ea283b781d1

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

module Alchemy
  module Admin
    module PagesHelper

      def tinymce_javascript_tags
        init = Alchemy::Tinymce.init
        if init.is_a?(Hash)
          init = HashWithIndifferentAccess.new(init)
          init = init.keys.sort.collect(&:to_s).sort.collect do |key|
            [key, init[key]]
          end
        end
        init = init.collect { |key, value| "#{key} : #{value.to_json}" }.join(', ')

        setup = "init.setup = #{Alchemy::Tinymce.setup};" if Alchemy::Tinymce.setup
        return "
    <script type='text/javascript'>
      jQuery(function(){
        if (typeof(Alchemy) !== 'object') { Alchemy = {}; };
        Alchemy.Tinymce = {
          init : function(callback) {
            var init = { #{init} };
            init.mode = 'specific_textareas';
            init.editor_selector = 'tinymce';
            init.plugins = '#{Alchemy::Tinymce.plugins.join(',')}';
            init.language = '#{::I18n.locale}';
            init.init_instance_callback = function(inst) {
              jQuery('#' + inst.editorId).prev('.essence_richtext_loader').hide();
            }
            if (callback)
              init.oninit = callback;
            #{setup}
            tinymce.init(init);
          },
          addEditor : function(dom_id) {
            tinymce.execCommand('mceAddControl', true, dom_id);
          }
        };
        Alchemy.Tinymce.init();
      });
    </script>".html_safe
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alchemy_cms-2.2.rc2 app/helpers/alchemy/admin/pages_helper.rb
alchemy_cms-2.2.rc1 app/helpers/alchemy/admin/pages_helper.rb