under-os-ui 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +26 -0
  3. data/lib/assets/fontawesome-webfont.ttf +0 -0
  4. data/lib/assets/under-os.css +115 -0
  5. data/lib/core/kernel.rb +16 -0
  6. data/lib/under-os-ui.rb +6 -0
  7. data/lib/under_os/app.rb +26 -0
  8. data/lib/under_os/config.rb +25 -0
  9. data/lib/under_os/history.rb +53 -0
  10. data/lib/under_os/page.rb +178 -0
  11. data/lib/under_os/page/builder.rb +96 -0
  12. data/lib/under_os/page/layout.rb +43 -0
  13. data/lib/under_os/page/matcher.rb +128 -0
  14. data/lib/under_os/page/stylesheet.rb +67 -0
  15. data/lib/under_os/parser.rb +24 -0
  16. data/lib/under_os/parser/css.rb +37 -0
  17. data/lib/under_os/parser/html.rb +97 -0
  18. data/lib/under_os/ui.rb +3 -0
  19. data/lib/under_os/ui/alert.rb +52 -0
  20. data/lib/under_os/ui/button.rb +42 -0
  21. data/lib/under_os/ui/collection.rb +65 -0
  22. data/lib/under_os/ui/collection/cell.rb +21 -0
  23. data/lib/under_os/ui/collection/delegate.rb +70 -0
  24. data/lib/under_os/ui/collection/item.rb +32 -0
  25. data/lib/under_os/ui/collection/layout.rb +43 -0
  26. data/lib/under_os/ui/collection/styles.rb +15 -0
  27. data/lib/under_os/ui/div.rb +3 -0
  28. data/lib/under_os/ui/form.rb +60 -0
  29. data/lib/under_os/ui/icon.rb +61 -0
  30. data/lib/under_os/ui/icon/awesome.rb +376 -0
  31. data/lib/under_os/ui/icon/engine.rb +9 -0
  32. data/lib/under_os/ui/image.rb +31 -0
  33. data/lib/under_os/ui/input.rb +140 -0
  34. data/lib/under_os/ui/label.rb +21 -0
  35. data/lib/under_os/ui/locker.rb +42 -0
  36. data/lib/under_os/ui/navbar.rb +123 -0
  37. data/lib/under_os/ui/progress.rb +17 -0
  38. data/lib/under_os/ui/scroll.rb +102 -0
  39. data/lib/under_os/ui/select.rb +95 -0
  40. data/lib/under_os/ui/sidebar.rb +45 -0
  41. data/lib/under_os/ui/slider.rb +37 -0
  42. data/lib/under_os/ui/spinner.rb +23 -0
  43. data/lib/under_os/ui/style.rb +21 -0
  44. data/lib/under_os/ui/style/fonts.rb +56 -0
  45. data/lib/under_os/ui/style/margins.rb +164 -0
  46. data/lib/under_os/ui/style/outlining.rb +170 -0
  47. data/lib/under_os/ui/style/positioning.rb +183 -0
  48. data/lib/under_os/ui/switch.rb +26 -0
  49. data/lib/under_os/ui/textarea.rb +19 -0
  50. data/lib/under_os/ui/utils/animation.rb +101 -0
  51. data/lib/under_os/ui/utils/commons.rb +70 -0
  52. data/lib/under_os/ui/utils/dimensions.rb +37 -0
  53. data/lib/under_os/ui/utils/events.rb +210 -0
  54. data/lib/under_os/ui/utils/manipulation.rb +44 -0
  55. data/lib/under_os/ui/utils/position.rb +21 -0
  56. data/lib/under_os/ui/utils/size.rb +21 -0
  57. data/lib/under_os/ui/utils/styles.rb +89 -0
  58. data/lib/under_os/ui/utils/traversing.rb +44 -0
  59. data/lib/under_os/ui/utils/wrap.rb +77 -0
  60. data/lib/under_os/ui/view.rb +31 -0
  61. data/spec/assets/app.css +13 -0
  62. data/spec/assets/test.css +7 -0
  63. data/spec/assets/test.html +3 -0
  64. data/spec/assets/test.png +0 -0
  65. data/spec/assets/test_page.rb +2 -0
  66. data/spec/under_os/page/builder_spec.rb +128 -0
  67. data/spec/under_os/page/layout_spec.rb +18 -0
  68. data/spec/under_os/page/matcher_spec.rb +260 -0
  69. data/spec/under_os/page/stylesheet_spec.rb +83 -0
  70. data/spec/under_os/page_spec.rb +5 -0
  71. data/spec/under_os/parser/css_spec.rb +77 -0
  72. data/spec/under_os/parser/html_spec.rb +152 -0
  73. data/spec/under_os/parser_spec.rb +16 -0
  74. data/spec/under_os/ui/button_spec.rb +50 -0
  75. data/spec/under_os/ui/collection_spec.rb +19 -0
  76. data/spec/under_os/ui/div_spec.rb +24 -0
  77. data/spec/under_os/ui/form_spec.rb +156 -0
  78. data/spec/under_os/ui/icon_spec.rb +57 -0
  79. data/spec/under_os/ui/image_spec.rb +39 -0
  80. data/spec/under_os/ui/input_spec.rb +109 -0
  81. data/spec/under_os/ui/label_spec.rb +22 -0
  82. data/spec/under_os/ui/locker_spec.rb +31 -0
  83. data/spec/under_os/ui/progress_spec.rb +31 -0
  84. data/spec/under_os/ui/scroll_spec.rb +75 -0
  85. data/spec/under_os/ui/select_spec.rb +135 -0
  86. data/spec/under_os/ui/sidebar_spec.rb +35 -0
  87. data/spec/under_os/ui/slider_spec.rb +69 -0
  88. data/spec/under_os/ui/spinner_spec.rb +57 -0
  89. data/spec/under_os/ui/style/fonts_spec.rb +111 -0
  90. data/spec/under_os/ui/style/margins_spec.rb +106 -0
  91. data/spec/under_os/ui/style/outlining_spec.rb +101 -0
  92. data/spec/under_os/ui/style/positioning_spec.rb +69 -0
  93. data/spec/under_os/ui/style_spec.rb +19 -0
  94. data/spec/under_os/ui/switch_spec.rb +60 -0
  95. data/spec/under_os/ui/textarea_spec.rb +34 -0
  96. data/spec/under_os/ui/utils/commons_spec.rb +81 -0
  97. data/spec/under_os/ui/utils/events_spec.rb +87 -0
  98. data/spec/under_os/ui/utils/manipulation_spec.rb +130 -0
  99. data/spec/under_os/ui/utils/styles_spec.rb +140 -0
  100. data/spec/under_os/ui/utils/traversing_spec.rb +124 -0
  101. data/spec/under_os/ui/utils/wrap_spec.rb +69 -0
  102. data/spec/under_os/ui/view_spec.rb +39 -0
  103. data/under-os-ui.gemspec +23 -0
  104. metadata +216 -0
@@ -0,0 +1,22 @@
1
+ describe UnderOs::UI::Label do
2
+ describe '#initialize' do
3
+ it "should spawn new inputs" do
4
+ label = UnderOs::UI::Label.new
5
+ label.class.should == UnderOs::UI::Label
6
+ end
7
+
8
+ it "should wrap the UILabel class" do
9
+ label = UnderOs::UI::Label.new
10
+ label._.class.should == UILabel
11
+ end
12
+
13
+ it "should accept the 'text' option" do
14
+ label = UnderOs::UI::Label.new(text: 'label text')
15
+ label.text.should == 'label text'
16
+ end
17
+
18
+ it "should assign correct tag name" do
19
+ UnderOs::UI::Label.new.tagName.should == 'LABEL'
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,31 @@
1
+ describe UnderOs::UI::Locker do
2
+ before do
3
+ @locker = UnderOs::UI::Locker.new
4
+ end
5
+
6
+ describe '#constructor' do
7
+ it "builds locker instances" do
8
+ @locker.class.should == UnderOs::UI::Locker
9
+ end
10
+
11
+ it "wraps plain UIView objects" do
12
+ @locker._.class.should == UIView
13
+ end
14
+
15
+ it "sets the LOCKER tag" do
16
+ @locker.tagName.should == "LOCKER"
17
+ end
18
+
19
+ it "builds the dialog box inside" do
20
+ @locker.first('view.locker-dialog').should.not == nil
21
+ @locker.first('view.locker-dialog spinner').should.not == nil
22
+ @locker.first('view.locker-dialog label').should.not == nil
23
+ end
24
+
25
+ it "accepts the label text" do
26
+ locker = UnderOs::UI::Locker.new(text: "Syncing...")
27
+ locker.first('label').text.should == "Syncing..."
28
+ locker.hasClass('with-label').should == true
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,31 @@
1
+ describe UnderOs::UI::Progress do
2
+ before do
3
+ @progress = UnderOs::UI::Progress.new
4
+ end
5
+
6
+ describe '#initialize' do
7
+ it "should build a spinner" do
8
+ @progress.class.should == UnderOs::UI::Progress
9
+ end
10
+
11
+ it "should wrap the UIProgressView" do
12
+ @progress._.class.should == UIProgressView
13
+ end
14
+
15
+ it "should have the correct tag name" do
16
+ @progress.tagName.should == 'PROGRESS'
17
+ end
18
+
19
+ it "should accept the 'value' option" do
20
+ progress = UnderOs::UI::Progress.new(value: 0.4)
21
+ progress.value.should == 0.4
22
+ end
23
+ end
24
+
25
+ describe '#value' do
26
+ it "should assign values correctly" do
27
+ @progress.value = 0.6
28
+ @progress._.progress.should == 0.6
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,75 @@
1
+ describe UnderOs::UI::Scroll do
2
+ before do
3
+ @scroll = UnderOs::UI::Scroll.new
4
+ end
5
+
6
+ describe '#initialize' do
7
+ it 'should build an UI:Scroll object' do
8
+ @scroll.class.should == UnderOs::UI::Scroll
9
+ end
10
+
11
+ it "should wrap an UIScrollView instance" do
12
+ @scroll._.class.should == UIScrollView
13
+ end
14
+
15
+ it "should have the SCROLL tag" do
16
+ @scroll.tagName.should == 'SCROLL'
17
+ end
18
+
19
+ it "should accept the 'paging' option" do
20
+ scroll = UnderOs::UI::Scroll.new(paging: true)
21
+ scroll.paging.should == true
22
+ end
23
+ end
24
+
25
+ describe '#paging' do
26
+ it "should return 'false' by default" do
27
+ @scroll.paging.should == false
28
+ end
29
+
30
+ it "should to switch it on" do
31
+ @scroll.paging = true
32
+ @scroll.paging.should == true
33
+ end
34
+
35
+ it "should fallback to false" do
36
+ @scroll.paging = 'weird stuff'
37
+ @scroll.paging.should == false
38
+ end
39
+ end
40
+
41
+ describe "#scale" do
42
+ it "should allow to read it" do
43
+ @scroll.scale.should == 1.0
44
+ end
45
+
46
+ it "should allow to set it" do
47
+ @scroll.scale = 2.4
48
+ @scroll._.zoomScale.should == 1.0 # it will fall back to it
49
+ end
50
+ end
51
+
52
+ describe "#minScale" do
53
+ it "should allow to read it" do
54
+ @scroll._.minimumZoomScale = 1.8
55
+ @scroll.minScale.should == 1.8
56
+ end
57
+
58
+ it "should allow to set it" do
59
+ @scroll.minScale = 2.7
60
+ @scroll._.minimumZoomScale.should == 2.7
61
+ end
62
+ end
63
+
64
+ describe "#maxScale" do
65
+ it "should allow to read it" do
66
+ @scroll._.maximumZoomScale = 1.8
67
+ @scroll.maxScale.should == 1.8
68
+ end
69
+
70
+ it "should allow to set it" do
71
+ @scroll.maxScale = 2.7
72
+ @scroll._.maximumZoomScale.should == 2.7
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,135 @@
1
+ describe UnderOs::UI::Select do
2
+ before do
3
+ @select = UnderOs::UI::Select.new
4
+ end
5
+
6
+ it "inherits fromthe UnderOs::UI::Input" do
7
+ (UnderOs::UI::Select < UnderOs::UI::Input).should == true
8
+ end
9
+
10
+ describe '#initialize' do
11
+ it "should make select instances" do
12
+ @select.class.should == UnderOs::UI::Select
13
+ end
14
+
15
+ it "should wrap UIPickerView" do
16
+ @select._.class.should == UIPickerView
17
+ end
18
+
19
+ it "should have tag SELECT" do
20
+ @select.tagName.should == 'SELECT'
21
+ end
22
+
23
+ it "should accept 'options' option" do
24
+ select = UnderOs::UI::Select.new(options: {
25
+ '1' => 'One', '2' => 'Two', '3' => 'Three'
26
+ })
27
+
28
+ select.options.should == {
29
+ '1' => 'One', '2' => 'Two', '3' => 'Three'
30
+ }
31
+ end
32
+
33
+ it "should accept 'value' option" do
34
+ select = UnderOs::UI::Select.new(value: 1)
35
+ select.value.should == '1'
36
+ end
37
+ end
38
+
39
+ describe '#optgroups' do
40
+ it "should return an empty list by default" do
41
+ @select.optgroups.should == [{}]
42
+ end
43
+
44
+ it "should allow to assign groups" do
45
+ @select.optgroups = [
46
+ {'1' => 'One'}, {'2' => 'Two'}, {'3' => 'Three'}
47
+ ]
48
+
49
+ @select.optgroups.should == [
50
+ {'1' => 'One'}, {'2' => 'Two'}, {'3' => 'Three'}
51
+ ]
52
+ end
53
+
54
+ it "should convert keys to strings and skip nils" do
55
+ @select.optgroups = [{
56
+ nil => 'One', :'2' => 'Two', :'3' => nil
57
+ }]
58
+
59
+ @select.optgroups.should == [{'2' => 'Two'}]
60
+ end
61
+ end
62
+
63
+ describe '#options' do
64
+ it "should return an empty hash by default" do
65
+ @select.options.should == {}
66
+ end
67
+
68
+ it "should allow to set new options" do
69
+ @select.options = {
70
+ '1' => 'One', '2' => 'Two', '3' => 'Three'
71
+ }
72
+
73
+ @select.options.should == {
74
+ '1' => 'One', '2' => 'Two', '3' => 'Three'
75
+ }
76
+ end
77
+
78
+ it "should overwrite the optgroups" do
79
+ @select.options = {
80
+ '1' => 'One', '2' => 'Two', '3' => 'Three'
81
+ }
82
+
83
+ @select.optgroups.should == [{
84
+ '1' => 'One', '2' => 'Two', '3' => 'Three'
85
+ }]
86
+ end
87
+ end
88
+
89
+ describe '#value' do
90
+ it "should return nil when nothing was set" do
91
+ @select.value.should == nil
92
+ end
93
+
94
+ it "should return an empty list if several optgroups were set" do
95
+ @select.optgroups = [
96
+ {'1' => 'One'}, {'2' => 'Two'}, {'3' => 'Three'}
97
+ ]
98
+
99
+ @select.value.should == []
100
+ end
101
+
102
+ it "should allow to set values for single selects" do
103
+ @select.value = 'one'
104
+ @select.value.should == 'one'
105
+ end
106
+
107
+ it "should allow to set values for multi-selects" do
108
+ @select.optgroups = [{'1' => 'One'}, {'2' => 'Two'}]
109
+ @select.value = ['1', '2']
110
+ @select.value.should == ['1', '2']
111
+ end
112
+
113
+ it "should convert all values to strings" do
114
+ @select.value = 1
115
+ @select.value.should == '1'
116
+ end
117
+
118
+ it "should emit the 'change' event if value was changed" do
119
+ @changed = false
120
+ @select.on(:change) { @changed = true }
121
+ @select.value = 'new'
122
+ @changed.should == true
123
+ end
124
+
125
+ it "should not emit the 'change' event if the same value was assigned" do
126
+ @select.value = 'same'
127
+
128
+ @changed = false
129
+ @select.on(:change) { @changed = true }
130
+ @select.value = 'same'
131
+
132
+ @changed.should == false
133
+ end
134
+ end
135
+ end
@@ -0,0 +1,35 @@
1
+ describe UnderOs::UI::Sidebar do
2
+ before do
3
+ @sidebar = UnderOs::UI::Sidebar.new
4
+ end
5
+
6
+ describe '#initialize' do
7
+ it "should build sidebars" do
8
+ @sidebar.class.should == UnderOs::UI::Sidebar
9
+ end
10
+
11
+ it "should wrap up a normal UIView" do
12
+ @sidebar._.class.should == UIView
13
+ end
14
+
15
+ it "should have the 'SIDEBAR' tag" do
16
+ @sidebar.tagName.should == "SIDEBAR"
17
+ end
18
+
19
+ it "should accept the 'location' option" do
20
+ sidebar = UnderOs::UI::Sidebar.new(location: :left)
21
+ sidebar.location.should == :left
22
+ end
23
+ end
24
+
25
+ describe '#location' do
26
+ it "should return :bottom by default" do
27
+ @sidebar.location.should == :bottom
28
+ end
29
+
30
+ it "should accept other values" do
31
+ @sidebar.location = 'top'
32
+ @sidebar.location.should == :top
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,69 @@
1
+ describe UnderOs::UI::Slider do
2
+ before do
3
+ @slider = UnderOs::UI::Slider.new
4
+ end
5
+
6
+ it "inherits fromthe UnderOs::UI::Input" do
7
+ (UnderOs::UI::Slider < UnderOs::UI::Input).should == true
8
+ end
9
+
10
+ describe '#initialize' do
11
+ it "should spawn new sliders" do
12
+ @slider.class.should == UnderOs::UI::Slider
13
+ end
14
+
15
+ it "should wrap the UISlider class" do
16
+ @slider._.class.should == UISlider
17
+ end
18
+
19
+ it "should assign correct tag name" do
20
+ @slider.tagName.should == 'SLIDER'
21
+ end
22
+
23
+ it "should accept the 'value' option" do
24
+ slider = UnderOs::UI::Slider.new(value: 0.4)
25
+ slider.value.should == 0.4
26
+ end
27
+
28
+ it "should accept the 'min' option" do
29
+ slider = UnderOs::UI::Slider.new(min: 4)
30
+ slider.min.should == 4
31
+ end
32
+
33
+ it "should accept the 'max' option" do
34
+ slider = UnderOs::UI::Slider.new(max: 4)
35
+ slider.max.should == 4
36
+ end
37
+ end
38
+
39
+ describe '#value' do
40
+ it "should assign the value property correctly" do
41
+ @slider.value = 0.25
42
+ @slider._.value.should == 0.25
43
+ end
44
+ end
45
+
46
+ describe '#min' do
47
+ it "should assign the minimal value boundaries correctly" do
48
+ @slider.min = -10
49
+ @slider._.minimumValue.should == -10
50
+ end
51
+
52
+ it "should return the minimum value as it is" do
53
+ @slider.min = -20
54
+ @slider.min.should == -20
55
+ end
56
+ end
57
+
58
+ describe '#max' do
59
+ it "should assign the maximal value boundaries correctly" do
60
+ @slider.max = -10
61
+ @slider._.maximumValue.should == -10
62
+ end
63
+
64
+ it "should return the maximum value as it is" do
65
+ @slider.max = -20
66
+ @slider.max.should == -20
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,57 @@
1
+ describe UnderOs::UI::Spinner do
2
+ before do
3
+ @spinner = UnderOs::UI::Spinner.new
4
+ end
5
+
6
+ describe 'constructor' do
7
+ it "should build a spinner" do
8
+ @spinner.class.should == UnderOs::UI::Spinner
9
+ end
10
+
11
+ it "should wrap the UIActivityIndicatorView" do
12
+ @spinner._.class.should == UIActivityIndicatorView
13
+ end
14
+
15
+ it "should have the correct tag name" do
16
+ @spinner.tagName.should == 'SPINNER'
17
+ end
18
+
19
+ it "should make it spin" do
20
+ @spinner.visible.should == true
21
+ end
22
+ end
23
+
24
+ describe '#show' do
25
+ # it "should start the spinner" do
26
+ # @spinner.show
27
+ # @spinner._.isAnimating.should == 1
28
+ # end
29
+
30
+ it "should return the spinner back" do
31
+ @spinner.should.be.same_as @spinner
32
+ end
33
+ end
34
+
35
+ describe '#hide' do
36
+ # it "should stop the spinner" do
37
+ # @spinner.hide
38
+ # @spinner._.isAnimating.should == 0
39
+ # end
40
+
41
+ it "should return the spinner instance back" do
42
+ @spinner.hide.should.be.same_as @spinner
43
+ end
44
+ end
45
+
46
+ describe '#hidden' do
47
+ # it "should return false when the spinner is active" do
48
+ # @spinner.show
49
+ # @spinner.hidden.should == false
50
+ # end
51
+
52
+ # it "should return true when the spinner is inactive" do
53
+ # @spinner.hide
54
+ # @spinner.hidden.should == true
55
+ # end
56
+ end
57
+ end