Class: Glimmer::SWT::MessageBoxProxy

Inherits:
WidgetProxy show all
Defined in:
lib/glimmer/swt/message_box_proxy.rb

Constant Summary

Constants inherited from WidgetProxy

WidgetProxy::DEFAULT_INITIALIZERS

Instance Attribute Summary collapse

Attributes inherited from WidgetProxy

#args, #background, #children, #enabled, #focus, #font, #foreground, #parent, #path

Instance Method Summary collapse

Methods inherited from WidgetProxy

#add_css_class, #add_css_classes, #add_observer, #apply_property_type_converters, #build_dom, #can_handle_observation_request?, #clear_css_classes, #css_classes, #dispose, #dom_element, #element, for, #handle_observation_request, #has_style?, #id, #id=, #listener_dom_element, max_id_number_for, max_id_numbers, next_id_number_for, #parent_dom_element, #parent_path, #post_add_content, #post_initialize_child, #property_type_converters, #remove_css_class, #remove_css_classes, #render, reset_max_id_numbers!, #set_attribute, #set_focus, #style_element, underscored_widget_name, widget_class, widget_exists?, #widget_property_listener_installers

Methods included from PropertyOwner

#attribute_getter, #attribute_setter, #get_attribute, #set_attribute

Constructor Details

#initialize(parent, args, block) ⇒ MessageBoxProxy

Returns a new instance of MessageBoxProxy.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/glimmer/swt/message_box_proxy.rb', line 9

def initialize(parent, args, block)
  i = 0
  @parent = parent || DisplayProxy.instance.shells.first
  @args = args
  @block = block
  @children = Set.new
  @enabled = true
  content do
    on_widget_selected {
      hide
    }
  end
end

Instance Attribute Details

#messageObject

Returns the value of attribute message.



7
8
9
# File 'lib/glimmer/swt/message_box_proxy.rb', line 7

def message
  @message
end

#textObject

Returns the value of attribute text.



7
8
9
# File 'lib/glimmer/swt/message_box_proxy.rb', line 7

def text
  @text
end

Instance Method Details

#content(&block) ⇒ Object



49
50
51
# File 'lib/glimmer/swt/message_box_proxy.rb', line 49

def content(&block)
  Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Opal::MessageBoxExpression.new, &block)
end

#documentObject



33
34
35
36
37
38
39
# File 'lib/glimmer/swt/message_box_proxy.rb', line 33

def document
  element = self
  begin
    element = element.parent
  end while(element.parent)
  element
end

#domObject



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/glimmer/swt/message_box_proxy.rb', line 118

def dom
  modal_id = id
  modal_style = css
  modal_text = text
  modal_message = message
  modal_class = ['modal', name].join(' ')
  @dom ||= html {
    div(id: modal_id, style: modal_style, class: modal_class) {
      style(class: 'modal-style') {
        style_dom_modal_css #.split("\n").map(&:strip).join(' ')
      }
      div(class: 'modal-content') {
        header(class: 'text') {
          modal_text
        }
        tag(_name: 'p', id: 'message', class: 'message') {
          modal_message
        }
        input(type: 'button', class: 'close', autofocus: 'autofocus', value: 'OK')
      }
    }
  }.to_s
end

#hideObject



45
46
47
# File 'lib/glimmer/swt/message_box_proxy.rb', line 45

def hide
  dom_element.remove
end

#listener_pathObject



61
62
63
# File 'lib/glimmer/swt/message_box_proxy.rb', line 61

def listener_path
  path + ' .close'
end

#nameObject



53
54
55
# File 'lib/glimmer/swt/message_box_proxy.rb', line 53

def name
  'div'
end

#observation_request_to_event_mappingObject



65
66
67
68
69
70
71
# File 'lib/glimmer/swt/message_box_proxy.rb', line 65

def observation_request_to_event_mapping
  {
    'on_widget_selected' => {
      event: 'click'
    },
  }
end

#openObject



41
42
43
# File 'lib/glimmer/swt/message_box_proxy.rb', line 41

def open
  document.post_initialize_child(self)
end

#selectorObject



57
58
59
# File 'lib/glimmer/swt/message_box_proxy.rb', line 57

def selector
  super + ' .close'
end

#style_dom_modal_cssObject



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/glimmer/swt/message_box_proxy.rb', line 73

def style_dom_modal_css
  "    .modal {\n      position: fixed;\n      z-index: 1;\n      padding-top: 100px;\n      left: 0;\n      top: 0;\n      width: 100%;\n      height: 100%;\n      overflow: auto;\n      background-color: rgb(0,0,0);\n      background-color: rgba(0,0,0,0.4);\n      text-align: center;\n    }\n    .modal-content .text {\n      background: rgb(80, 116, 211);\n      color: white;\n      padding: 5px;\n    }\n    .modal-content .message {\n      padding: 20px;\n    }\n    .modal-content {\n      background-color: #fefefe;\n      padding-bottom: 15px;\n      border: 1px solid #888;\n      display: inline-block;\n      min-width: 200px;\n    }\n  CSS\n#           .close {\n#             color: #aaaaaa;\n#             float: right;\n#             font-weight: bold;\n#             margin: 5px;\n#           }\n#           .close:hover,\n#           .close:focus {\n#             color: #000;\n#             text-decoration: none;\n#             cursor: pointer;\n#           }\nend\n"