Sha256: a3c626495dfefc0a635a56527a56b9e51846003c32ffa07faa75e59b1f08264a
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
module JellyHelper def application_jelly_files(jelly_files_path_from_javascripts = '', rails_root = RAILS_ROOT) rails_root = File.expand_path(rails_root) ( Dir[File.expand_path("#{rails_root}/public/javascripts/#{jelly_files_path_from_javascripts}/components/**/*.js")] + Dir[File.expand_path("#{rails_root}/public/javascripts/#{jelly_files_path_from_javascripts}/pages/**/*.js")] ).map do |path| path.gsub("#{rails_root}/public/javascripts/", "").gsub(/\.js$/, "") end end def spread_jelly javascript_tag <<-JS window._token = '#{form_authenticity_token}' Jelly.activatePage('#{controller.controller_path.camelcase}', '#{controller.action_name}'); #{@content_for_javascript} $(document).ready(function() { #{@content_for_javascript_on_ready} }); JS end def clear_jelly_attached() @jelly_attached_components = [] end def attach_javascript_component(component_name, *args) @jelly_attached_components ||= [] key = "page.attach(#{component_name}, #{args.to_json});" unless @jelly_attached_components.include? key @jelly_attached_components << key content_for(:javascript, key) end end def attach_javascript_component_on_ready(component_name, *args) @jelly_attached_components_on_ready ||= [] key = "page.attach(#{component_name}, #{args.to_json});" unless @jelly_attached_components_on_ready.include? key @jelly_attached_components_on_ready << key content_for(:javascript_on_ready, key) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
btakita-jelly-0.6.1 | lib/jelly/jelly_helper.rb |