Sha256: dca8e737fd4bf2bc098c337032ab910ec4616a6f3dc54fb5f800cfea9d097999
Contents?: true
Size: 1.64 KB
Versions: 1
Compression:
Stored size: 1.64 KB
Contents
module TimelineJS module Rails module Helper # https://github.com/NUKnightLab/TimelineJS#using-inline-easiest # @example # <%= timeline_config(embed_id: 'my-timeline', source: 'path_to_json/or_link_to_googlespreadsheet') %> def timeline_config(options = {}) turbolink = options.delete(:turbolink) turbolink = turbolink.nil? ? true : turbolink output = "<div id='#{options[:embed_id]}'></div>" output << javascript_tag("var timeline_config = #{default_timelinejs_options.merge(options).to_json};") output << javascript_include_tag('timelineJS', 'data-turbolinks-track' => turbolink) raw(output) end # https://github.com/NUKnightLab/TimelineJS#using-a-method-advanced # @example # <%= create_storyJS('my-timeline', source: 'path_to_json/or_link_to_googlespreadsheet') %> def create_storyJS(embed_id, options = {}) options[:embed_id] = embed_id options[:type] = 'timeline' unless options[:type] turbolink = options.delete(:turbolink) turbolink = turbolink.nil? ? true : turbolink output = javascript_include_tag('timelineJS', 'data-turbolinks-track' => turbolink) output << javascript_tag do <<-SCRIPT $(document).ready(function() { createStoryJS(#{ default_timelinejs_options.merge(options).to_json }); }); SCRIPT end raw(output) end protected # You can override this method in your view. def default_timelinejs_options {width: '100%', height: '600'} end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
timelineJS_rails-2.17 | lib/timelineJS/rails/helper.rb |