module LazyHighCharts::LayoutHelper

Public Instance Methods

high_chart_iruby(chart_class, placeholder, object, &block) click to toggle source
# File lib/daru/view/adapters/highcharts/layout_helper_iruby.rb, line 3
def high_chart_iruby(chart_class, placeholder, object, &block)
  object.html_options[:id] = placeholder
  object.options[:chart][:renderTo] = placeholder
  build_html_output_iruby(
    chart_class, placeholder, object, &block
  ).concat(content_tag('div', '', object.html_options))
end
high_map(placeholder, object, &block) click to toggle source
# File lib/daru/view/adapters/highcharts/layout_helper_iruby.rb, line 11
def high_map(placeholder, object, &block)
  object.html_options[:id] = placeholder
  object.options[:chart][:renderTo] = placeholder
  build_html_output(
    'Map', placeholder, object, &block
  ).concat(content_tag('div', '', object.html_options))
end

Private Instance Methods

build_html_output_iruby(type, placeholder, object, &block) click to toggle source
# File lib/daru/view/adapters/highcharts/layout_helper_iruby.rb, line 21
    def build_html_output_iruby(type, placeholder, object, &block)
      core_js =<<-EOJS
        var options = #{options_collection_as_string(object)};
        #{capture(&block) if block_given?}
        window.chart_#{placeholder.underscore} = new Highcharts.#{type}(options);
      EOJS

      encapsulate_js_iruby core_js
    end
call_core_js(core_js) click to toggle source
# File lib/daru/view/adapters/highcharts/layout_helper_iruby.rb, line 75
    def call_core_js(core_js)
      <<-EOJS
      #{js_start_iruby}
        #{core_js}
      #{js_end_iruby}
      EOJS
    end
encapsulate_js_iruby(core_js) click to toggle source
# File lib/daru/view/adapters/highcharts/layout_helper_iruby.rb, line 31
def encapsulate_js_iruby(core_js)
  js_output =
    if request_is_xhr?
      "#{js_start_iruby} #{core_js} #{js_end_iruby}"
    # Turbolinks.version < 5
    elsif defined?(Turbolinks)
      encapsulate_js_for_turbolinks(core_js)
    else
      call_core_js(core_js)
    end

  defined?(raw) ? raw(js_output) : js_output
end
eventlistener_page_load(core_js) click to toggle source
# File lib/daru/view/adapters/highcharts/layout_helper_iruby.rb, line 53
    def eventlistener_page_load(core_js)
      <<-EOJS
      #{js_start_iruby}
        var f = function(){
          document.removeEventListener('page:load', f, true);
          #{core_js}
        };
        document.addEventListener('page:load', f, true);
      #{js_end_iruby}
      EOJS
    end
js_end_iruby() click to toggle source
# File lib/daru/view/adapters/highcharts/layout_helper_iruby.rb, line 90
    def js_end_iruby
      <<-EOJS
        });
        </script>
      EOJS
    end
js_start_iruby() click to toggle source
# File lib/daru/view/adapters/highcharts/layout_helper_iruby.rb, line 83
    def js_start_iruby
      <<-EOJS
        <script type="text/javascript">
        $(function() {
      EOJS
    end