glimmer-dsl-opal 0.0.7 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +56 -0
- data/README.md +815 -76
- data/VERSION +1 -1
- data/lib/glimmer-dsl-opal.rb +45 -8
- data/lib/glimmer-dsl-opal/ext/date.rb +13 -0
- data/lib/glimmer-dsl-opal/ext/exception.rb +5 -0
- data/lib/glimmer-dsl-opal/missing/net/http.rb +17 -0
- data/lib/glimmer-dsl-opal/missing/uri.rb +64 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager.rb +2 -3
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact_manager_presenter.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact_repository.rb +24 -99
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/login.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/tic_tac_toe.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/tic_tac_toe/board.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/tic_tac_toe/cell.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_browser.rb +0 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_combo.rb +63 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_computed.rb +19 -19
- data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_computed/contact.rb +0 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +155 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_widget.rb +86 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_list_multi_selection.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_list_single_selection.rb +0 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_tab.rb +50 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_world.rb +29 -0
- data/lib/glimmer-dsl-opal/vendor/jquery.js +2 -0
- data/lib/glimmer/data_binding/element_binding.rb +1 -1
- data/lib/glimmer/data_binding/ext/observable_model.rb +6 -6
- data/lib/glimmer/data_binding/list_selection_binding.rb +1 -1
- data/lib/glimmer/data_binding/table_items_binding.rb +70 -0
- data/lib/glimmer/dsl/opal/async_exec_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/color_expression.rb +38 -0
- data/lib/glimmer/dsl/opal/column_properties_expression.rb +22 -0
- data/lib/glimmer/dsl/opal/combo_selection_data_binding_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/custom_widget_expression.rb +77 -0
- data/lib/glimmer/dsl/opal/dsl.rb +15 -14
- data/lib/glimmer/dsl/opal/font_expression.rb +47 -0
- data/lib/glimmer/dsl/opal/layout_data_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/layout_expression.rb +22 -0
- data/lib/glimmer/dsl/opal/list_selection_data_binding_expression.rb +2 -3
- data/lib/glimmer/dsl/opal/message_box_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/property_expression.rb +5 -2
- data/lib/glimmer/dsl/opal/rgb_expression.rb +32 -0
- data/lib/glimmer/dsl/opal/rgba_expression.rb +32 -0
- data/lib/glimmer/dsl/opal/shell_expression.rb +18 -2
- data/lib/glimmer/dsl/opal/swt_expression.rb +46 -0
- data/lib/glimmer/dsl/opal/{composite_expression.rb → table_column_expression.rb} +3 -3
- data/lib/glimmer/dsl/opal/{list_expression.rb → table_expression.rb} +3 -3
- data/lib/glimmer/dsl/opal/table_items_data_binding_expression.rb +29 -0
- data/lib/glimmer/dsl/opal/widget_expression.rb +24 -0
- data/lib/glimmer/dsl/opal/widget_listener_expression.rb +16 -3
- data/lib/glimmer/swt.rb +499 -0
- data/lib/glimmer/swt/browser_proxy.rb +27 -0
- data/lib/glimmer/swt/button_proxy.rb +40 -0
- data/lib/glimmer/swt/color_proxy.rb +119 -0
- data/lib/glimmer/{opal/select_proxy.rb → swt/combo_proxy.rb} +24 -19
- data/lib/glimmer/swt/composite_proxy.rb +31 -0
- data/lib/glimmer/{opal → swt}/display_proxy.rb +6 -4
- data/lib/glimmer/{opal → swt}/event_listener_proxy.rb +1 -1
- data/lib/glimmer/swt/fill_layout_proxy.rb +84 -0
- data/lib/glimmer/swt/font_proxy.rb +79 -0
- data/lib/glimmer/swt/grid_layout_proxy.rb +71 -0
- data/lib/glimmer/swt/label_proxy.rb +34 -0
- data/lib/glimmer/swt/layout_data_proxy.rb +87 -0
- data/lib/glimmer/swt/layout_proxy.rb +63 -0
- data/lib/glimmer/{opal → swt}/list_proxy.rb +31 -23
- data/lib/glimmer/swt/message_box_proxy.rb +143 -0
- data/lib/glimmer/{opal → swt}/point.rb +1 -1
- data/lib/glimmer/{opal → swt}/property_owner.rb +1 -1
- data/lib/glimmer/swt/row_layout_proxy.rb +105 -0
- data/lib/glimmer/swt/shell_proxy.rb +246 -0
- data/lib/glimmer/swt/style_constantizable.rb +154 -0
- data/lib/glimmer/swt/swt_proxy.rb +53 -0
- data/lib/glimmer/{opal/tab_folder.rb → swt/tab_folder_proxy.rb} +21 -15
- data/lib/glimmer/swt/tab_item_proxy.rb +84 -0
- data/lib/glimmer/swt/table_column_proxy.rb +56 -0
- data/lib/glimmer/swt/table_item_proxy.rb +147 -0
- data/lib/glimmer/swt/table_proxy.rb +159 -0
- data/lib/glimmer/swt/text_proxy.rb +46 -0
- data/lib/glimmer/swt/widget_proxy.rb +490 -0
- data/lib/glimmer/ui/custom_shell.rb +91 -0
- data/lib/glimmer/ui/custom_widget.rb +291 -0
- data/lib/glimmer/util/proc_tracker.rb +39 -0
- metadata +131 -76
- data/lib/glimmer/config.rb +0 -22
- data/lib/glimmer/dsl/engine.rb +0 -193
- data/lib/glimmer/dsl/expression.rb +0 -42
- data/lib/glimmer/dsl/expression_handler.rb +0 -48
- data/lib/glimmer/dsl/opal/browser_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/button_expression.rb +0 -18
- data/lib/glimmer/dsl/opal/combo_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/grid_layout_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/label_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/tab_folder_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/tab_item_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/text_expression.rb +0 -22
- data/lib/glimmer/dsl/parent_expression.rb +0 -12
- data/lib/glimmer/dsl/static_expression.rb +0 -36
- data/lib/glimmer/dsl/top_level_expression.rb +0 -7
- data/lib/glimmer/error.rb +0 -6
- data/lib/glimmer/invalid_keyword_error.rb +0 -6
- data/lib/glimmer/opal/div_proxy.rb +0 -22
- data/lib/glimmer/opal/document_proxy.rb +0 -178
- data/lib/glimmer/opal/element_proxy.rb +0 -287
- data/lib/glimmer/opal/grid_layout_proxy.rb +0 -54
- data/lib/glimmer/opal/iframe_proxy.rb +0 -23
- data/lib/glimmer/opal/input_proxy.rb +0 -45
- data/lib/glimmer/opal/label_proxy.rb +0 -25
- data/lib/glimmer/opal/layout_data_proxy.rb +0 -31
- data/lib/glimmer/opal/modal.rb +0 -94
- data/lib/glimmer/opal/tab_item.rb +0 -98
- data/lib/samples/elaborate/launch +0 -6
- data/lib/samples/hello/hello_combo.rb +0 -34
- data/lib/samples/hello/hello_tab.rb +0 -24
- data/lib/samples/hello/hello_world.rb +0 -8
- data/lib/samples/hello/launch +0 -10
- data/lib/samples/launch +0 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.3.0
|
data/lib/glimmer-dsl-opal.rb
CHANGED
@@ -1,11 +1,48 @@
|
|
1
1
|
require 'opal'
|
2
|
-
require 'opal-async'
|
3
|
-
require 'glimmer'
|
4
2
|
|
5
|
-
|
6
|
-
|
3
|
+
if RUBY_PLATFORM == 'opal'
|
4
|
+
GLIMMER_DSL_OPAL_ROOT = File.expand_path('../..', __FILE__)
|
5
|
+
GLIMMER_DSL_OPAL_LIB = File.join(GLIMMER_DSL_OPAL_ROOT, 'lib')
|
6
|
+
GLIMMER_DSL_OPAL_MISSING = File.join(GLIMMER_DSL_OPAL_ROOT, 'lib', 'glimmer-dsl-opal', 'missing')
|
7
|
+
|
8
|
+
$LOAD_PATH.unshift(GLIMMER_DSL_OPAL_LIB)
|
9
|
+
$LOAD_PATH.unshift(GLIMMER_DSL_OPAL_MISSING) # missing Ruby classes/methods
|
10
|
+
|
11
|
+
require 'opal-parser'
|
12
|
+
require 'native' # move this to opal-async
|
13
|
+
require 'opal-async'
|
14
|
+
require 'async/ext'
|
15
|
+
require 'glimmer-dsl-opal/vendor/jquery'
|
16
|
+
require 'opal-jquery'
|
17
|
+
require 'glimmer'
|
18
|
+
require 'facets/hash/symbolize_keys'
|
19
|
+
require 'glimmer-dsl-opal/ext/exception'
|
20
|
+
require 'glimmer-dsl-opal/ext/date'
|
21
|
+
require 'glimmer-dsl-opal/missing/uri'
|
7
22
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
23
|
+
# Spiking async logging
|
24
|
+
# logger = Glimmer::Config.logger
|
25
|
+
# original_add_method = logger.class.instance_method(:add)
|
26
|
+
# logger.define_singleton_method("__original_add", original_add_method)
|
27
|
+
# logger.singleton_class.send(:define_method, :add) do |*args|
|
28
|
+
# Async::Timeout.new 10000 do
|
29
|
+
# __original_add(*args)
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
|
33
|
+
require 'glimmer/dsl/opal/dsl'
|
34
|
+
require 'glimmer/data_binding/ext/observable_model'
|
35
|
+
|
36
|
+
require 'glimmer-dsl-xml'
|
37
|
+
require 'glimmer-dsl-css'
|
38
|
+
Element.alias_native :replace_with, :replaceWith
|
39
|
+
|
40
|
+
# Glimmer::Config.loop_max_count = 20
|
41
|
+
|
42
|
+
Glimmer::Config.excluded_keyword_checkers << lambda do |method_symbol, *args|
|
43
|
+
method = method_symbol.to_s
|
44
|
+
result = false
|
45
|
+
result ||= method == '<<'
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'time'
|
3
|
+
|
4
|
+
class DateTime < Date
|
5
|
+
def initialize(*args, &block)
|
6
|
+
@time = Time.new(*args, &block)
|
7
|
+
@time.methods.each do |method|
|
8
|
+
singleton_class.define_method(method) do |*args, &block|
|
9
|
+
@time.send(method, *args, &block)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Missing Net module class methods TODO implement
|
2
|
+
|
3
|
+
require_relative '../uri'
|
4
|
+
|
5
|
+
module Net
|
6
|
+
# TODO Implement HTTP with jQuery for use in Glimmer DSL for Opal
|
7
|
+
# Note: ignore Protocol superclass for now
|
8
|
+
class HTTP
|
9
|
+
def post_form(uri, params)
|
10
|
+
# pd uri.scheme
|
11
|
+
# pd uri.host
|
12
|
+
# pd uri.path
|
13
|
+
# pd uri.query
|
14
|
+
# pd params
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# Missing URI module class features
|
2
|
+
|
3
|
+
module URI
|
4
|
+
class HTTP
|
5
|
+
REGEX = /([^:]+):\/\/([^\/])\/([^?]*)\??(.*)/
|
6
|
+
|
7
|
+
def initialize(url)
|
8
|
+
@url = url
|
9
|
+
uri_match = url.match(REGEX)
|
10
|
+
@scheme = uri_match[1]
|
11
|
+
@host = uri_match[2]
|
12
|
+
@path = uri_match[3]
|
13
|
+
@query = uri_match[4]
|
14
|
+
# TODO fragment
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_s
|
18
|
+
url
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
TBLENCWWWCOMP_ = {"\u0000"=>"%00", "\u0001"=>"%01", "\u0002"=>"%02", "\u0003"=>"%03", "\u0004"=>"%04", "\u0005"=>"%05", "\u0006"=>"%06", "\a"=>"%07", "\b"=>"%08", "\t"=>"%09", "\n"=>"%0A", "\v"=>"%0B", "\f"=>"%0C", "\r"=>"%0D", "\u000E"=>"%0E", "\u000F"=>"%0F", "\u0010"=>"%10", "\u0011"=>"%11", "\u0012"=>"%12", "\u0013"=>"%13", "\u0014"=>"%14", "\u0015"=>"%15", "\u0016"=>"%16", "\u0017"=>"%17", "\u0018"=>"%18", "\u0019"=>"%19", "\u001A"=>"%1A", "\e"=>"%1B", "\u001C"=>"%1C", "\u001D"=>"%1D", "\u001E"=>"%1E", "\u001F"=>"%1F", " "=>"+", "!"=>"%21", "\""=>"%22", "#"=>"%23", "$"=>"%24", "%"=>"%25", "&"=>"%26", "'"=>"%27", "("=>"%28", ")"=>"%29", "*"=>"%2A", "+"=>"%2B", ","=>"%2C", "-"=>"%2D", "."=>"%2E", "/"=>"%2F", "0"=>"%30", "1"=>"%31", "2"=>"%32", "3"=>"%33", "4"=>"%34", "5"=>"%35", "6"=>"%36", "7"=>"%37", "8"=>"%38", "9"=>"%39", ":"=>"%3A", ";"=>"%3B", "<"=>"%3C", "="=>"%3D", ">"=>"%3E", "?"=>"%3F", "@"=>"%40", "A"=>"%41", "B"=>"%42", "C"=>"%43", "D"=>"%44", "E"=>"%45", "F"=>"%46", "G"=>"%47", "H"=>"%48", "I"=>"%49", "J"=>"%4A", "K"=>"%4B", "L"=>"%4C", "M"=>"%4D", "N"=>"%4E", "O"=>"%4F", "P"=>"%50", "Q"=>"%51", "R"=>"%52", "S"=>"%53", "T"=>"%54", "U"=>"%55", "V"=>"%56", "W"=>"%57", "X"=>"%58", "Y"=>"%59", "Z"=>"%5A", "["=>"%5B", "\\"=>"%5C", "]"=>"%5D", "^"=>"%5E", "_"=>"%5F", "`"=>"%60", "a"=>"%61", "b"=>"%62", "c"=>"%63", "d"=>"%64", "e"=>"%65", "f"=>"%66", "g"=>"%67", "h"=>"%68", "i"=>"%69", "j"=>"%6A", "k"=>"%6B", "l"=>"%6C", "m"=>"%6D", "n"=>"%6E", "o"=>"%6F", "p"=>"%70", "q"=>"%71", "r"=>"%72", "s"=>"%73", "t"=>"%74", "u"=>"%75", "v"=>"%76", "w"=>"%77", "x"=>"%78", "y"=>"%79", "z"=>"%7A", "{"=>"%7B", "|"=>"%7C", "}"=>"%7D", "~"=>"%7E", "\u007F"=>"%7F", "\u0080"=>"%80", "\u0081"=>"%81", "\u0082"=>"%82", "\u0083"=>"%83", "\u0084"=>"%84", "\u0085"=>"%85", "\u0086"=>"%86", "\u0087"=>"%87", "\u0088"=>"%88", "\u0089"=>"%89", "\u008A"=>"%8A", "\u008B"=>"%8B", "\u008C"=>"%8C", "\u008D"=>"%8D", "\u008E"=>"%8E", "\u008F"=>"%8F", "\u0090"=>"%90", "\u0091"=>"%91", "\u0092"=>"%92", "\u0093"=>"%93", "\u0094"=>"%94", "\u0095"=>"%95", "\u0096"=>"%96", "\u0097"=>"%97", "\u0098"=>"%98", "\u0099"=>"%99", "\u009A"=>"%9A", "\u009B"=>"%9B", "\u009C"=>"%9C", "\u009D"=>"%9D", "\u009E"=>"%9E", "\u009F"=>"%9F", "\u00A0"=>"%A0", "\u00A1"=>"%A1", "\u00A2"=>"%A2", "\u00A3"=>"%A3", "\u00A4"=>"%A4", "\u00A5"=>"%A5", "\u00A6"=>"%A6", "\u00A7"=>"%A7", "\u00A8"=>"%A8", "\u00A9"=>"%A9", "\u00AA"=>"%AA", "\u00AB"=>"%AB", "\u00AC"=>"%AC", "\u00AD"=>"%AD", "\u00AE"=>"%AE", "\u00AF"=>"%AF", "\u00B0"=>"%B0", "\u00B1"=>"%B1", "\u00B2"=>"%B2", "\u00B3"=>"%B3", "\u00B4"=>"%B4", "\u00B5"=>"%B5", "\u00B6"=>"%B6", "\u00B7"=>"%B7", "\u00B8"=>"%B8", "\u00B9"=>"%B9", "\u00BA"=>"%BA", "\u00BB"=>"%BB", "\u00BC"=>"%BC", "\u00BD"=>"%BD", "\u00BE"=>"%BE", "\u00BF"=>"%BF", "\u00C0"=>"%C0", "\u00C1"=>"%C1", "\u00C2"=>"%C2", "\u00C3"=>"%C3", "\u00C4"=>"%C4", "\u00C5"=>"%C5", "\u00C6"=>"%C6", "\u00C7"=>"%C7", "\u00C8"=>"%C8", "\u00C9"=>"%C9", "\u00CA"=>"%CA", "\u00CB"=>"%CB", "\u00CC"=>"%CC", "\u00CD"=>"%CD", "\u00CE"=>"%CE", "\u00CF"=>"%CF", "\u00D0"=>"%D0", "\u00D1"=>"%D1", "\u00D2"=>"%D2", "\u00D3"=>"%D3", "\u00D4"=>"%D4", "\u00D5"=>"%D5", "\u00D6"=>"%D6", "\u00D7"=>"%D7", "\u00D8"=>"%D8", "\u00D9"=>"%D9", "\u00DA"=>"%DA", "\u00DB"=>"%DB", "\u00DC"=>"%DC", "\u00DD"=>"%DD", "\u00DE"=>"%DE", "\u00DF"=>"%DF", "\u00E0"=>"%E0", "\u00E1"=>"%E1", "\u00E2"=>"%E2", "\u00E3"=>"%E3", "\u00E4"=>"%E4", "\u00E5"=>"%E5", "\u00E6"=>"%E6", "\u00E7"=>"%E7", "\u00E8"=>"%E8", "\u00E9"=>"%E9", "\u00EA"=>"%EA", "\u00EB"=>"%EB", "\u00EC"=>"%EC", "\u00ED"=>"%ED", "\u00EE"=>"%EE", "\u00EF"=>"%EF", "\u00F0"=>"%F0", "\u00F1"=>"%F1", "\u00F2"=>"%F2", "\u00F3"=>"%F3", "\u00F4"=>"%F4", "\u00F5"=>"%F5", "\u00F6"=>"%F6", "\u00F7"=>"%F7", "\u00F8"=>"%F8", "\u00F9"=>"%F9", "\u00FA"=>"%FA", "\u00FB"=>"%FB", "\u00FC"=>"%FC", "\u00FD"=>"%FD", "\u00FE"=>"%FE", "\u00FF"=>"%FF"}.freeze
|
23
|
+
TBLDECWWWCOMP_ = TBLENCWWWCOMP_.invert.freeze
|
24
|
+
|
25
|
+
# Encodes given +str+ to URL-encoded form data.
|
26
|
+
#
|
27
|
+
# This method doesn't convert *, -, ., 0-9, A-Z, _, a-z, but does convert SP
|
28
|
+
# (ASCII space) to + and converts others to %XX.
|
29
|
+
#
|
30
|
+
# If +enc+ is given, convert +str+ to the encoding before percent encoding.
|
31
|
+
#
|
32
|
+
# This is an implementation of
|
33
|
+
# https://www.w3.org/TR/2013/CR-html5-20130806/forms.html#url-encoded-form-data.
|
34
|
+
#
|
35
|
+
# See URI.decode_www_form_component, URI.encode_www_form.
|
36
|
+
def self.encode_www_form_component(str, enc=nil)
|
37
|
+
str = str.to_s.dup
|
38
|
+
if str.encoding != Encoding::ASCII_8BIT
|
39
|
+
if enc && enc != Encoding::ASCII_8BIT
|
40
|
+
str.encode!(Encoding::UTF_8, invalid: :replace, undef: :replace)
|
41
|
+
str.encode!(enc, fallback: ->(x){"&##{x.ord};"})
|
42
|
+
end
|
43
|
+
str.force_encoding(Encoding::ASCII_8BIT)
|
44
|
+
end
|
45
|
+
str = str.gsub(/[^*\-.0-9A-Z_a-z]/, TBLENCWWWCOMP_)
|
46
|
+
str.force_encoding(Encoding::US_ASCII)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Decodes given +str+ of URL-encoded form data.
|
50
|
+
#
|
51
|
+
# This decodes + to SP.
|
52
|
+
#
|
53
|
+
# See URI.encode_www_form_component, URI.decode_www_form.
|
54
|
+
def self.decode_www_form_component(str, enc=Encoding::UTF_8)
|
55
|
+
raise ArgumentError, "invalid %-encoding (#{str})" if /%(?![0-9a-fA-F][0-9a-fA-F])/ =~ str
|
56
|
+
str.b.gsub(/\+|%[0-9a-fA-F][0-9a-fA-F]/, TBLDECWWWCOMP_).force_encoding(enc)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
module Kernel
|
61
|
+
def URI(url)
|
62
|
+
URI::HTTP.new(url)
|
63
|
+
end
|
64
|
+
end
|
@@ -81,9 +81,8 @@ class ContactManager
|
|
81
81
|
@contact_manager_presenter.toggle_sort(:email)
|
82
82
|
}
|
83
83
|
}
|
84
|
-
items bind(@contact_manager_presenter, :results),
|
85
|
-
|
86
|
-
on_mouse_down { |event|
|
84
|
+
items bind(@contact_manager_presenter, :results), column_properties(:first_name, :last_name, :email)
|
85
|
+
on_mouse_up { |event|
|
87
86
|
table_proxy.edit_table_item(event.table_item, event.column_index)
|
88
87
|
}
|
89
88
|
}
|
File without changes
|
data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact_manager_presenter.rb
RENAMED
File without changes
|
data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact_repository.rb
RENAMED
@@ -1,3 +1,24 @@
|
|
1
|
+
# Copyright (c) 2007-2020 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
1
22
|
require_relative "contact"
|
2
23
|
|
3
24
|
class ContactManager
|
@@ -103,105 +124,8 @@ class ContactManager
|
|
103
124
|
Jason
|
104
125
|
Emma
|
105
126
|
Olivia
|
106
|
-
Ava
|
107
|
-
Isabella
|
108
|
-
Sophia
|
109
|
-
Charlotte
|
110
|
-
Mia
|
111
|
-
Amelia
|
112
|
-
Harper
|
113
|
-
Evelyn
|
114
|
-
Abigail
|
115
|
-
Emily
|
116
|
-
Elizabeth
|
117
|
-
Mila
|
118
|
-
Ella
|
119
|
-
Avery
|
120
|
-
Sofia
|
121
|
-
Camila
|
122
|
-
Aria
|
123
|
-
Scarlett
|
124
|
-
Victoria
|
125
|
-
Madison
|
126
|
-
Luna
|
127
|
-
Grace
|
128
|
-
Chloe
|
129
|
-
Penelope
|
130
|
-
Layla
|
131
|
-
Riley
|
132
|
-
Zoey
|
133
|
-
Nora
|
134
|
-
Lily
|
135
|
-
Eleanor
|
136
|
-
Hannah
|
137
|
-
Lillian
|
138
|
-
Addison
|
139
|
-
Aubrey
|
140
|
-
Ellie
|
141
|
-
Stella
|
142
|
-
Natalie
|
143
|
-
Zoe
|
144
|
-
Leah
|
145
|
-
Hazel
|
146
|
-
Violet
|
147
|
-
Aurora
|
148
|
-
Savannah
|
149
|
-
Audrey
|
150
|
-
Brooklyn
|
151
|
-
Bella
|
152
|
-
Claire
|
153
|
-
Skylar
|
154
|
-
Lucy
|
155
|
-
Paisley
|
156
|
-
Everly
|
157
|
-
Anna
|
158
|
-
Caroline
|
159
|
-
Nova
|
160
|
-
Genesis
|
161
|
-
Emilia
|
162
|
-
Kennedy
|
163
|
-
Samantha
|
164
|
-
Maya
|
165
|
-
Willow
|
166
|
-
Kinsley
|
167
|
-
Naomi
|
168
|
-
Aaliyah
|
169
|
-
Elena
|
170
|
-
Sarah
|
171
|
-
Ariana
|
172
|
-
Allison
|
173
|
-
Gabriella
|
174
|
-
Alice
|
175
|
-
Madelyn
|
176
|
-
Cora
|
177
|
-
Ruby
|
178
|
-
Eva
|
179
|
-
Serenity
|
180
|
-
Autumn
|
181
|
-
Adeline
|
182
|
-
Hailey
|
183
|
-
Gianna
|
184
|
-
Valentina
|
185
|
-
Isla
|
186
|
-
Eliana
|
187
|
-
Quinn
|
188
|
-
Nevaeh
|
189
|
-
Ivy
|
190
|
-
Sadie
|
191
|
-
Piper
|
192
|
-
Lydia
|
193
|
-
Alexa
|
194
|
-
Josephine
|
195
|
-
Emery
|
196
|
-
Julia
|
197
|
-
Delilah
|
198
|
-
Arianna
|
199
|
-
Vivian
|
200
|
-
Kaylee
|
201
|
-
Sophie
|
202
|
-
Brielle
|
203
|
-
Madeline
|
204
127
|
]
|
128
|
+
|
205
129
|
NAMES_LAST = %w[
|
206
130
|
Smith
|
207
131
|
Johnson
|
@@ -214,8 +138,9 @@ class ContactManager
|
|
214
138
|
Anderson
|
215
139
|
Taylor
|
216
140
|
]
|
141
|
+
|
217
142
|
def initialize(contacts = nil)
|
218
|
-
@contacts = contacts ||
|
143
|
+
@contacts = contacts || 100.times.map do |n|
|
219
144
|
random_first_name_index = (rand*NAMES_FIRST.size).to_i
|
220
145
|
random_last_name_index = (rand*NAMES_LAST.size).to_i
|
221
146
|
first_name = NAMES_FIRST[random_first_name_index]
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Copyright (c) 2020 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
class Person
|
23
|
+
attr_accessor :country, :country_options
|
24
|
+
|
25
|
+
def initialize
|
26
|
+
self.country_options = ['', 'Canada', 'US', 'Mexico']
|
27
|
+
reset_country
|
28
|
+
end
|
29
|
+
|
30
|
+
def reset_country
|
31
|
+
self.country = 'Canada'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class HelloCombo
|
36
|
+
include Glimmer
|
37
|
+
|
38
|
+
def launch
|
39
|
+
person = Person.new
|
40
|
+
|
41
|
+
shell {
|
42
|
+
row_layout(:vertical) {
|
43
|
+
pack false
|
44
|
+
}
|
45
|
+
|
46
|
+
text 'Hello, Combo!'
|
47
|
+
|
48
|
+
combo(:read_only) {
|
49
|
+
selection bind(person, :country)
|
50
|
+
}
|
51
|
+
|
52
|
+
button {
|
53
|
+
text 'Reset Selection'
|
54
|
+
|
55
|
+
on_widget_selected do
|
56
|
+
person.reset_country
|
57
|
+
end
|
58
|
+
}
|
59
|
+
}.open
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
HelloCombo.new.launch
|
@@ -1,19 +1,19 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative 'hello_computed/contact'
|
2
2
|
|
3
3
|
class HelloComputed
|
4
4
|
include Glimmer
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
@contact = Contact.new(
|
8
|
-
first_name:
|
9
|
-
last_name:
|
8
|
+
first_name: 'Barry',
|
9
|
+
last_name: 'McKibbin',
|
10
10
|
year_of_birth: 1985
|
11
11
|
)
|
12
12
|
end
|
13
13
|
|
14
14
|
def launch
|
15
15
|
shell {
|
16
|
-
text
|
16
|
+
text 'Hello, Computed!'
|
17
17
|
composite {
|
18
18
|
grid_layout {
|
19
19
|
num_columns 2
|
@@ -21,44 +21,44 @@ class HelloComputed
|
|
21
21
|
horizontal_spacing 20
|
22
22
|
vertical_spacing 10
|
23
23
|
}
|
24
|
-
label {text
|
24
|
+
label {text 'First &Name: '}
|
25
25
|
text {
|
26
26
|
text bind(@contact, :first_name)
|
27
27
|
layout_data {
|
28
|
-
|
29
|
-
|
28
|
+
horizontal_alignment :fill
|
29
|
+
grab_excess_horizontal_space true
|
30
30
|
}
|
31
31
|
}
|
32
|
-
label {text
|
32
|
+
label {text '&Last Name: '}
|
33
33
|
text {
|
34
34
|
text bind(@contact, :last_name)
|
35
35
|
layout_data {
|
36
|
-
|
37
|
-
|
36
|
+
horizontal_alignment :fill
|
37
|
+
grab_excess_horizontal_space true
|
38
38
|
}
|
39
39
|
}
|
40
|
-
label {text
|
40
|
+
label {text '&Year of Birth: '}
|
41
41
|
text {
|
42
42
|
text bind(@contact, :year_of_birth)
|
43
43
|
layout_data {
|
44
|
-
|
45
|
-
|
44
|
+
horizontal_alignment :fill
|
45
|
+
grab_excess_horizontal_space true
|
46
46
|
}
|
47
47
|
}
|
48
|
-
label {text
|
48
|
+
label {text 'Name: '}
|
49
49
|
label {
|
50
50
|
text bind(@contact, :name, computed_by: [:first_name, :last_name])
|
51
51
|
layout_data {
|
52
|
-
|
53
|
-
|
52
|
+
horizontal_alignment :fill
|
53
|
+
grab_excess_horizontal_space true
|
54
54
|
}
|
55
55
|
}
|
56
|
-
label {text
|
56
|
+
label {text 'Age: '}
|
57
57
|
label {
|
58
58
|
text bind(@contact, :age, on_write: :to_i, computed_by: [:year_of_birth])
|
59
59
|
layout_data {
|
60
|
-
|
61
|
-
|
60
|
+
horizontal_alignment :fill
|
61
|
+
grab_excess_horizontal_space true
|
62
62
|
}
|
63
63
|
}
|
64
64
|
}
|