<commit_before>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
        tinymce_javascript_string = "
        <script type='text/javascript'>
          jQuery(function($) {
            if (typeof(Alchemy) !== 'object') { Alchemy = {}; };
            Alchemy.Tinymce = {
              init : function(callback) {
                var init = { #{init} };
                var spinner = Alchemy.Spinner.small();
                $('.tinymce_container').prepend(spinner.spin().el);
                init.mode = 'specific_textareas';
                init.editor_selector = 'default_tinymce';
                init.plugins = '#{Alchemy::Tinymce.plugins.join(',')}';
                init.language = '#{::I18n.locale.to_s.split('-')[0].downcase }';
                init.init_instance_callback = function(inst) {
                  spinner.stop();
                }
                if (callback)
                  init.oninit = callback;
                #{setup}
                tinymce.init(init);
              },<commit_msg>Removes spinner after initializing TinyMCE instance.<commit_after>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
        tinymce_javascript_string = "
        <script type='text/javascript'>
          jQuery(function($) {
            if (typeof(Alchemy) !== 'object') { Alchemy = {}; };
            Alchemy.Tinymce = {
              init : function(callback) {
                var init = { #{init} };
                var spinner = Alchemy.Spinner.small();
                $('.tinymce_container').prepend(spinner.spin().el);
                init.mode = 'specific_textareas';
                init.editor_selector = 'default_tinymce';
                init.plugins = '#{Alchemy::Tinymce.plugins.join(',')}';
                init.language = '#{::I18n.locale.to_s.split('-')[0].downcase }';
                init.init_instance_callback = function(inst) {
                  $('#' + inst.editorId).prev('.spinner').remove();
                }
                if (callback)
                  init.oninit = callback;
                #{setup}
                tinymce.init(init);
              },
{'fraction_non_alphanumeric': 0.14180847514180847, 'fraction_numerical': 0.002002002002002002, 'mean_word_length': 1.740402193784278, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '119595', 'n_tokens_mistral': 920, 'n_tokens_neox': 865, 'n_words': 143}