Class: Glimmer::DSL::Opal::ShellExpression

Inherits:
StaticExpression
  • Object
show all
Includes:
ParentExpression, TopLevelExpression
Defined in:
lib/glimmer/dsl/opal/shell_expression.rb

Instance Method Summary collapse

Instance Method Details

#add_content(parent, keyword, *args, &block) ⇒ Object



30
31
32
33
# File 'lib/glimmer/dsl/opal/shell_expression.rb', line 30

def add_content(parent, keyword, *args, &block)
  super(parent, keyword, *args, &block)
  parent.post_add_content
end

#interpret(parent, keyword, *args, &block) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/glimmer/dsl/opal/shell_expression.rb', line 16

def interpret(parent, keyword, *args, &block)
  if Glimmer::UI::CustomShell.requested_and_not_handled?
    parameters = Glimmer::UI::CustomShell.request_parameter_string.split("&").map {|str| str.split("=")}.to_h
    `history.pushState(#{parameters.merge('custom_shell_handled' => 'true')}, document.title, #{"?#{Glimmer::UI::CustomShell.encoded_request_parameter_string}&custom_shell_handled=true"})`
    custom_shell_keyword = parameters.delete('custom_shell')
    CustomWidgetExpression.new.interpret(nil, custom_shell_keyword, *[parameters])
    `history.pushState(#{parameters.reject {|k,v| k == 'custom_shell_handled'}}, document.title, #{"?#{Glimmer::UI::CustomShell.encoded_request_parameter_string.sub('&custom_shell_handled=true', '')}"})`
    # just a placeholder that has an open method # TODO return an actual CustomShell in the future that does the work happening above in the #open method
    Glimmer::SWT::MakeShiftShellProxy.new
  else
    Glimmer::SWT::ShellProxy.new(args)
  end
end