Sha256: f0324b6096d01f739bf45ab6ba19bfef2d1a70223ed289ef9e331fbb2a806fd0

Contents?: true

Size: 1.8 KB

Versions: 9

Compression:

Stored size: 1.8 KB

Contents

require 'glimmer/dsl/static_expression'
require 'glimmer/dsl/top_level_expression'
require 'glimmer/dsl/parent_expression'
require 'glimmer/swt/shell_proxy'
require 'glimmer/swt/make_shift_shell_proxy'
require 'glimmer/ui/custom_shell'
require 'glimmer/dsl/opal/custom_widget_expression'

module Glimmer
  module DSL
    module Opal
      class ShellExpression < StaticExpression
        include TopLevelExpression
        include ParentExpression

        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
        
        def add_content(parent, &content)
          content.call(parent) if parent.is_a?(Glimmer::SWT::ShellProxy)
        end

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
glimmer-dsl-opal-0.8.0 lib/glimmer/dsl/opal/shell_expression.rb
glimmer-dsl-opal-0.7.5 lib/glimmer/dsl/opal/shell_expression.rb
glimmer-dsl-opal-0.7.4 lib/glimmer/dsl/opal/shell_expression.rb
glimmer-dsl-opal-0.7.3 lib/glimmer/dsl/opal/shell_expression.rb
glimmer-dsl-opal-0.7.2 lib/glimmer/dsl/opal/shell_expression.rb
glimmer-dsl-opal-0.7.1 lib/glimmer/dsl/opal/shell_expression.rb
glimmer-dsl-opal-0.7.0 lib/glimmer/dsl/opal/shell_expression.rb
glimmer-dsl-opal-0.6.1 lib/glimmer/dsl/opal/shell_expression.rb
glimmer-dsl-opal-0.6.0 lib/glimmer/dsl/opal/shell_expression.rb