Module: Card::Set::All::HeadJavascript::HtmlFormat

Extended by:
Card::Set::AbstractFormat
Defined in:
platypus/tmp/set/gem-defaults/mod019-script/all/head_javascript.rb

Instance Method Summary collapse

Instance Method Details

#decko_script_variablesObject



36
37
38
39
40
41
42
43
# File 'platypus/tmp/set/gem-defaults/mod019-script/all/head_javascript.rb', line 36

def decko_script_variables
  {
    "decko.rootUrl": card_url(""),
    "decko.doubleClick": Card.config.double_click,
    "decko.cssPath": head_stylesheet_path,
    "decko.currentUserId": (Auth.current_id if Auth.signed_in?)
  }
end

#head_javascript_pathsObject



45
46
47
48
49
50
51
52
# File 'platypus/tmp/set/gem-defaults/mod019-script/all/head_javascript.rb', line 45

def head_javascript_paths
  return unless (asset_card = param_or_rule_card :script)

  seed_asset_outputs asset_card
  asset_card.item_cards.map do |script|
    script.format(:html).render :javascript_include_tag
  end
end

#view: javascript_include_tagObject



32
33
34
# File 'platypus/tmp/set/gem-defaults/mod019-script/all/head_javascript.rb', line 32

view :javascript_include_tag, cache: :never, unknown: true, perms: :none do
  "\n<!-- javascript_include_tag not overridden for #{card.name} -->\n"
end

#view: javascript_tagsObject



24
25
26
# File 'platypus/tmp/set/gem-defaults/mod019-script/all/head_javascript.rb', line 24

view :javascript_tags, unknown: true, cache: :deep, perms: :none do
  Array.wrap(head_javascript_paths).reject(&:empty?).join
end

#view: script_callsObject



28
29
30
# File 'platypus/tmp/set/gem-defaults/mod019-script/all/head_javascript.rb', line 28

view :script_calls, unknown: true, perms: :none do
  javascript_tag { (script_configs << trigger_slot_ready).join "\n\n" }
end

#view: script_variablesObject



16
17
18
19
20
21
22
# File 'platypus/tmp/set/gem-defaults/mod019-script/all/head_javascript.rb', line 16

view :script_variables, unknown: true, cache: :never, perms: :none do
  javascript_tag do
    decko_script_variables.each_with_object("") do |(k, v), string|
      string << "#{k}=#{script_variable_to_js v};\n"
    end
  end
end