diamonds 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +36 -0
- data/lib/diamonds.rb +74 -0
- data/lib/diamonds/Gemfile +28 -0
- data/lib/diamonds/README.md +254 -0
- data/lib/diamonds/Rakefile +5 -0
- data/lib/diamonds/apps/application.rb +15 -0
- data/lib/diamonds/apps/library.rb +321 -0
- data/lib/diamonds/apps/user_app.rb +5 -0
- data/lib/diamonds/config.ru +98 -0
- data/lib/diamonds/db/mysiteDB Back.sqlite3 +0 -0
- data/lib/diamonds/db/mysiteDB.sqlite3 +0 -0
- data/lib/diamonds/gems/auto_launch_browser.rb +22 -0
- data/lib/diamonds/gems/io.rb +146 -0
- data/lib/diamonds/gems/ruby_to_js.rb +173 -0
- data/lib/diamonds/gems/server_utils.rb +96 -0
- data/lib/diamonds/lib/opal-browser.rb +1 -0
- data/lib/diamonds/lib/opal/browser.rb +4 -0
- data/lib/diamonds/opal-browser.gemspec +21 -0
- data/lib/diamonds/opal/browser.rb +11 -0
- data/lib/diamonds/opal/browser/animation_frame.rb +111 -0
- data/lib/diamonds/opal/browser/canvas.rb +321 -0
- data/lib/diamonds/opal/browser/canvas/data.rb +63 -0
- data/lib/diamonds/opal/browser/canvas/gradient.rb +27 -0
- data/lib/diamonds/opal/browser/canvas/style.rb +113 -0
- data/lib/diamonds/opal/browser/canvas/text.rb +45 -0
- data/lib/diamonds/opal/browser/console.rb +103 -0
- data/lib/diamonds/opal/browser/cookies.rb +133 -0
- data/lib/diamonds/opal/browser/css.rb +24 -0
- data/lib/diamonds/opal/browser/css/declaration.rb +83 -0
- data/lib/diamonds/opal/browser/css/rule.rb +48 -0
- data/lib/diamonds/opal/browser/css/rule/style.rb +16 -0
- data/lib/diamonds/opal/browser/css/style_sheet.rb +83 -0
- data/lib/diamonds/opal/browser/css/unit.rb +188 -0
- data/lib/diamonds/opal/browser/database/sql.rb +194 -0
- data/lib/diamonds/opal/browser/delay.rb +78 -0
- data/lib/diamonds/opal/browser/dom.rb +84 -0
- data/lib/diamonds/opal/browser/dom/attribute.rb +26 -0
- data/lib/diamonds/opal/browser/dom/builder.rb +88 -0
- data/lib/diamonds/opal/browser/dom/cdata.rb +9 -0
- data/lib/diamonds/opal/browser/dom/character_data.rb +73 -0
- data/lib/diamonds/opal/browser/dom/comment.rb +9 -0
- data/lib/diamonds/opal/browser/dom/document.rb +149 -0
- data/lib/diamonds/opal/browser/dom/document_fragment.rb +7 -0
- data/lib/diamonds/opal/browser/dom/element.rb +474 -0
- data/lib/diamonds/opal/browser/dom/element/attributes.rb +87 -0
- data/lib/diamonds/opal/browser/dom/element/data.rb +67 -0
- data/lib/diamonds/opal/browser/dom/element/image.rb +23 -0
- data/lib/diamonds/opal/browser/dom/element/input.rb +28 -0
- data/lib/diamonds/opal/browser/dom/element/offset.rb +89 -0
- data/lib/diamonds/opal/browser/dom/element/position.rb +46 -0
- data/lib/diamonds/opal/browser/dom/element/scroll.rb +136 -0
- data/lib/diamonds/opal/browser/dom/element/select.rb +36 -0
- data/lib/diamonds/opal/browser/dom/element/size.rb +34 -0
- data/lib/diamonds/opal/browser/dom/element/template.rb +9 -0
- data/lib/diamonds/opal/browser/dom/element/textarea.rb +24 -0
- data/lib/diamonds/opal/browser/dom/mutation_observer.rb +178 -0
- data/lib/diamonds/opal/browser/dom/node.rb +464 -0
- data/lib/diamonds/opal/browser/dom/node_set.rb +110 -0
- data/lib/diamonds/opal/browser/dom/text.rb +36 -0
- data/lib/diamonds/opal/browser/effects.rb +50 -0
- data/lib/diamonds/opal/browser/event.rb +253 -0
- data/lib/diamonds/opal/browser/event/animation.rb +38 -0
- data/lib/diamonds/opal/browser/event/audio_processing.rb +33 -0
- data/lib/diamonds/opal/browser/event/base.rb +430 -0
- data/lib/diamonds/opal/browser/event/before_unload.rb +15 -0
- data/lib/diamonds/opal/browser/event/clipboard.rb +28 -0
- data/lib/diamonds/opal/browser/event/close.rb +47 -0
- data/lib/diamonds/opal/browser/event/composition.rb +50 -0
- data/lib/diamonds/opal/browser/event/custom.rb +65 -0
- data/lib/diamonds/opal/browser/event/device_light.rb +23 -0
- data/lib/diamonds/opal/browser/event/device_motion.rb +51 -0
- data/lib/diamonds/opal/browser/event/device_orientation.rb +48 -0
- data/lib/diamonds/opal/browser/event/device_proximity.rb +33 -0
- data/lib/diamonds/opal/browser/event/drag.rb +119 -0
- data/lib/diamonds/opal/browser/event/focus.rb +39 -0
- data/lib/diamonds/opal/browser/event/gamepad.rb +60 -0
- data/lib/diamonds/opal/browser/event/hash_change.rb +28 -0
- data/lib/diamonds/opal/browser/event/keyboard.rb +115 -0
- data/lib/diamonds/opal/browser/event/message.rb +70 -0
- data/lib/diamonds/opal/browser/event/mouse.rb +254 -0
- data/lib/diamonds/opal/browser/event/page_transition.rb +23 -0
- data/lib/diamonds/opal/browser/event/pop_state.rb +33 -0
- data/lib/diamonds/opal/browser/event/progress.rb +43 -0
- data/lib/diamonds/opal/browser/event/sensor.rb +15 -0
- data/lib/diamonds/opal/browser/event/storage.rb +43 -0
- data/lib/diamonds/opal/browser/event/touch.rb +60 -0
- data/lib/diamonds/opal/browser/event/ui.rb +38 -0
- data/lib/diamonds/opal/browser/event/wheel.rb +49 -0
- data/lib/diamonds/opal/browser/event_source.rb +70 -0
- data/lib/diamonds/opal/browser/history.rb +90 -0
- data/lib/diamonds/opal/browser/http.rb +169 -0
- data/lib/diamonds/opal/browser/http/binary.rb +58 -0
- data/lib/diamonds/opal/browser/http/headers.rb +109 -0
- data/lib/diamonds/opal/browser/http/request.rb +344 -0
- data/lib/diamonds/opal/browser/http/response.rb +115 -0
- data/lib/diamonds/opal/browser/immediate.rb +163 -0
- data/lib/diamonds/opal/browser/interval.rb +111 -0
- data/lib/diamonds/opal/browser/location.rb +87 -0
- data/lib/diamonds/opal/browser/navigator.rb +173 -0
- data/lib/diamonds/opal/browser/screen.rb +66 -0
- data/lib/diamonds/opal/browser/socket.rb +123 -0
- data/lib/diamonds/opal/browser/storage.rb +252 -0
- data/lib/diamonds/opal/browser/support.rb +287 -0
- data/lib/diamonds/opal/browser/utils.rb +74 -0
- data/lib/diamonds/opal/browser/version.rb +3 -0
- data/lib/diamonds/opal/browser/window.rb +120 -0
- data/lib/diamonds/opal/browser/window/scroll.rb +59 -0
- data/lib/diamonds/opal/browser/window/size.rb +59 -0
- data/lib/diamonds/opal/browser/window/view.rb +36 -0
- data/lib/diamonds/opal/opal-browser.rb +1 -0
- data/lib/diamonds/public/__OPAL_SOURCE_MAPS__/application.map +0 -0
- data/lib/diamonds/public/javascripts/font-awesome/HELP-US-OUT.txt +7 -0
- data/lib/diamonds/public/javascripts/font-awesome/css/font-awesome.css +2026 -0
- data/lib/diamonds/public/javascripts/font-awesome/css/font-awesome.min.css +1 -0
- data/lib/diamonds/public/javascripts/font-awesome/fonts/FontAwesome.otf +0 -0
- data/lib/diamonds/public/javascripts/font-awesome/fonts/fontawesome-webfont.eot +0 -0
- data/lib/diamonds/public/javascripts/font-awesome/fonts/fontawesome-webfont.svg +640 -0
- data/lib/diamonds/public/javascripts/font-awesome/fonts/fontawesome-webfont.ttf +0 -0
- data/lib/diamonds/public/javascripts/font-awesome/fonts/fontawesome-webfont.woff +0 -0
- data/lib/diamonds/public/javascripts/font-awesome/fonts/fontawesome-webfont.woff2 +0 -0
- data/lib/diamonds/public/javascripts/font-awesome/less/animated.less +34 -0
- data/lib/diamonds/public/javascripts/font-awesome/less/bordered-pulled.less +25 -0
- data/lib/diamonds/public/javascripts/font-awesome/less/core.less +12 -0
- data/lib/diamonds/public/javascripts/font-awesome/less/fixed-width.less +6 -0
- data/lib/diamonds/public/javascripts/font-awesome/less/font-awesome.less +17 -0
- data/lib/diamonds/public/javascripts/font-awesome/less/icons.less +677 -0
- data/lib/diamonds/public/javascripts/font-awesome/less/larger.less +13 -0
- data/lib/diamonds/public/javascripts/font-awesome/less/list.less +19 -0
- data/lib/diamonds/public/javascripts/font-awesome/less/mixins.less +26 -0
- data/lib/diamonds/public/javascripts/font-awesome/less/path.less +15 -0
- data/lib/diamonds/public/javascripts/font-awesome/less/rotated-flipped.less +20 -0
- data/lib/diamonds/public/javascripts/font-awesome/less/stacked.less +20 -0
- data/lib/diamonds/public/javascripts/font-awesome/less/variables.less +688 -0
- data/lib/diamonds/public/javascripts/font-awesome/scss/_animated.scss +34 -0
- data/lib/diamonds/public/javascripts/font-awesome/scss/_bordered-pulled.scss +25 -0
- data/lib/diamonds/public/javascripts/font-awesome/scss/_core.scss +12 -0
- data/lib/diamonds/public/javascripts/font-awesome/scss/_fixed-width.scss +6 -0
- data/lib/diamonds/public/javascripts/font-awesome/scss/_icons.scss +677 -0
- data/lib/diamonds/public/javascripts/font-awesome/scss/_larger.scss +13 -0
- data/lib/diamonds/public/javascripts/font-awesome/scss/_list.scss +19 -0
- data/lib/diamonds/public/javascripts/font-awesome/scss/_mixins.scss +26 -0
- data/lib/diamonds/public/javascripts/font-awesome/scss/_path.scss +15 -0
- data/lib/diamonds/public/javascripts/font-awesome/scss/_rotated-flipped.scss +20 -0
- data/lib/diamonds/public/javascripts/font-awesome/scss/_stacked.scss +20 -0
- data/lib/diamonds/public/javascripts/font-awesome/scss/_variables.scss +688 -0
- data/lib/diamonds/public/javascripts/font-awesome/scss/font-awesome.scss +17 -0
- data/lib/diamonds/public/javascripts/jquery-2.1.4.min.js +4 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-bg_flat_10_000000_40x100.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-icons_222222_256x240.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-icons_228ef1_256x240.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-icons_ef8c08_256x240.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-icons_ffd27a_256x240.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/images/ui-icons_ffffff_256x240.png +0 -0
- data/lib/diamonds/public/javascripts/jquery-ui/jquery-ui.min.css +7 -0
- data/lib/diamonds/public/javascripts/jquery-ui/jquery-ui.min.js +13 -0
- data/lib/diamonds/public/javascripts/jquery-ui/jquery-ui.structure.min.css +5 -0
- data/lib/diamonds/public/javascripts/jquery-ui/jquery-ui.theme.min.css +5 -0
- data/lib/diamonds/public/javascripts/jquery.js +4 -0
- data/lib/diamonds/public/javascripts/jquery.ui.touch-punch.min.js +11 -0
- data/lib/diamonds/public/javascripts/ne pas utiliser version en retard jeezs_editor.js b/data/lib/diamonds/public/javascripts/ne pas utiliser version en retard → jeezs_editor.js +0 -0
- data/lib/diamonds/public/javascripts/standalone.js +2316 -0
- data/lib/diamonds/public/javascripts/standalone.min.js +1 -0
- data/lib/diamonds/public/javascripts/wysiwyg-editor.min.css +1 -0
- data/lib/diamonds/public/javascripts/wysiwyg-editor.min.js +1 -0
- data/lib/diamonds/public/javascripts/wysiwyg.min.js +1 -0
- data/lib/diamonds/user_app/main.rb +45 -0
- data/lib/diamonds/version.rb +3 -0
- data/lib/diamonds/views/index.erb +35 -0
- data/lib/diamonds/views/javascripts/jeezs_editor.js.erb +365 -0
- data/lib/diamonds/views/stylesheets/main.css.erb +244 -0
- metadata +490 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
module Browser; class Event
|
2
|
+
|
3
|
+
class PageTransition < Event
|
4
|
+
def self.supported?
|
5
|
+
Browser.supports? 'Event.PageTransition'
|
6
|
+
end
|
7
|
+
|
8
|
+
class Definition < Definition
|
9
|
+
def persisted=(value)
|
10
|
+
`#@native.persisted = #{value}`
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
if Browser.supports? 'Event.PageTransition'
|
15
|
+
def self.construct(name, desc)
|
16
|
+
`new PageTransitionEvent(name, desc)`
|
17
|
+
end
|
18
|
+
end if supported?
|
19
|
+
|
20
|
+
alias_native :persisted?, :persisted
|
21
|
+
end
|
22
|
+
|
23
|
+
end; end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Browser; class Event
|
2
|
+
|
3
|
+
class PopState < Event
|
4
|
+
def self.supported?
|
5
|
+
Browser.supports? 'Event.PopState'
|
6
|
+
end
|
7
|
+
|
8
|
+
class Definition < Definition
|
9
|
+
def state=(value)
|
10
|
+
`#@native.state = #{value}`
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
if Browser.supports? 'Event.constructor'
|
15
|
+
def self.construct(name, desc)
|
16
|
+
`new PopStateEvent(#{name}, #{desc})`
|
17
|
+
end
|
18
|
+
elsif Browser.supports? 'Event.create'
|
19
|
+
def self.construct(name, desc)
|
20
|
+
%x{
|
21
|
+
var event = document.createEvent('PopStateEvent');
|
22
|
+
event.initPopStateEvent(name, desc.bubbles, desc.cancelable,
|
23
|
+
desc.state);
|
24
|
+
|
25
|
+
return event;
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end if supported?
|
29
|
+
|
30
|
+
alias_native :state
|
31
|
+
end
|
32
|
+
|
33
|
+
end; end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Browser; class Event
|
2
|
+
|
3
|
+
class Progress < Event
|
4
|
+
def self.supported?
|
5
|
+
Browser.supports? 'Event.Progress'
|
6
|
+
end
|
7
|
+
|
8
|
+
class Definition < Definition
|
9
|
+
def computable=(value)
|
10
|
+
`#@native.computableLength = #{value}`
|
11
|
+
end
|
12
|
+
|
13
|
+
def loaded=(value)
|
14
|
+
`#@native.loaded = #{value}`
|
15
|
+
end
|
16
|
+
|
17
|
+
def total=(value)
|
18
|
+
`#@native.total = #{value}`
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
if Browser.supports? 'Event.constructor'
|
23
|
+
def self.construct(name, desc)
|
24
|
+
`new ProgressEvent(#{name}, #{desc})`
|
25
|
+
end
|
26
|
+
elsif Browser.supports? 'Event.create'
|
27
|
+
def self.construct(name, desc)
|
28
|
+
%x{
|
29
|
+
var event = document.createEvent("ProgressEvent");
|
30
|
+
event.initProgressEvent(name, desc.bubbles, desc.cancelable,
|
31
|
+
desc.computable, desc.loaded, desc.total);
|
32
|
+
|
33
|
+
return event;
|
34
|
+
}
|
35
|
+
end
|
36
|
+
end if supported?
|
37
|
+
|
38
|
+
alias_native :computable?, :computableLength
|
39
|
+
alias_native :loaded
|
40
|
+
alias_native :total
|
41
|
+
end
|
42
|
+
|
43
|
+
end; end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Browser; class Event
|
2
|
+
|
3
|
+
class Sensor < Event
|
4
|
+
def self.supported?
|
5
|
+
Browser.supports? 'Event.Sensor'
|
6
|
+
end
|
7
|
+
|
8
|
+
if Browser.supports? 'Event.constructor'
|
9
|
+
def self.construct(name, desc)
|
10
|
+
`new SensorEvent(#{name}, #{desc})`
|
11
|
+
end
|
12
|
+
end if supported?
|
13
|
+
end
|
14
|
+
|
15
|
+
end; end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Browser; class Event
|
2
|
+
|
3
|
+
class Storage < Event
|
4
|
+
def self.supported?
|
5
|
+
Browser.supports? 'Event.Storage'
|
6
|
+
end
|
7
|
+
|
8
|
+
class Definition < Definition
|
9
|
+
def key=(value)
|
10
|
+
`#@native.key = #{value}`
|
11
|
+
end
|
12
|
+
|
13
|
+
def new=(value)
|
14
|
+
`#@native.newValue = #{value}`
|
15
|
+
end
|
16
|
+
|
17
|
+
def old=(value)
|
18
|
+
`#@native.oldValue = #{value}`
|
19
|
+
end
|
20
|
+
|
21
|
+
def area=(value)
|
22
|
+
`#@native.storageArea = #{value}`
|
23
|
+
end
|
24
|
+
|
25
|
+
def url=(value)
|
26
|
+
`#@native.url = #{value}`
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
if Browser.supports? 'Event.constructor'
|
31
|
+
def self.construct(name, desc)
|
32
|
+
`new StorageEvent(#{name}, #{desc})`
|
33
|
+
end
|
34
|
+
end if supported?
|
35
|
+
|
36
|
+
alias_native :key
|
37
|
+
alias_native :new, :newValue
|
38
|
+
alias_native :old, :oldValue
|
39
|
+
alias_native :area, :storageArea
|
40
|
+
alias_native :url
|
41
|
+
end
|
42
|
+
|
43
|
+
end; end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Browser; class Event
|
2
|
+
|
3
|
+
class Touch < Event
|
4
|
+
def self.supported?
|
5
|
+
Browser.supports? 'Event.Touch'
|
6
|
+
end
|
7
|
+
|
8
|
+
class Definition < Definition
|
9
|
+
def alt!
|
10
|
+
`#@native.altKey = true`
|
11
|
+
end
|
12
|
+
|
13
|
+
def ctrl!
|
14
|
+
`#@native.ctrlKey = true`
|
15
|
+
end
|
16
|
+
|
17
|
+
def meta!
|
18
|
+
`#@native.metaKey = true`
|
19
|
+
end
|
20
|
+
|
21
|
+
def shift!
|
22
|
+
`#@native.shiftKey = true`
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
if Browser.supports? 'Event.constructor'
|
27
|
+
def self.construct(name, desc)
|
28
|
+
`new TouchEvent(#{name}, #{desc})`
|
29
|
+
end
|
30
|
+
end if supported?
|
31
|
+
|
32
|
+
alias_native :alt?, :altKey
|
33
|
+
alias_native :ctrl?, :ctrlKey
|
34
|
+
alias_native :meta?, :metaKey
|
35
|
+
alias_native :shift?, :shiftKey
|
36
|
+
|
37
|
+
# TODO: implement touches and targetTouches
|
38
|
+
|
39
|
+
def cancel?
|
40
|
+
name.downcase == 'touchcancel'
|
41
|
+
end
|
42
|
+
|
43
|
+
def end?
|
44
|
+
name.downcase == 'touchend'
|
45
|
+
end
|
46
|
+
|
47
|
+
def leave?
|
48
|
+
name.downcase == 'touchleave'
|
49
|
+
end
|
50
|
+
|
51
|
+
def move?
|
52
|
+
name.downcase == 'touchmove'
|
53
|
+
end
|
54
|
+
|
55
|
+
def start?
|
56
|
+
name.downcase == 'touchstart'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end; end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Browser; class Event
|
2
|
+
|
3
|
+
class UI < Event
|
4
|
+
def self.supported?
|
5
|
+
Browser.supports? 'Event.UI'
|
6
|
+
end
|
7
|
+
|
8
|
+
class Definition < Definition
|
9
|
+
def detail=(value)
|
10
|
+
`#@native.detail = #{value}`
|
11
|
+
end
|
12
|
+
|
13
|
+
def view=(value)
|
14
|
+
`#@native.view = #{value}`
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
if Browser.supports? 'Event.constructor'
|
19
|
+
def self.construct(name, desc)
|
20
|
+
`new UIEvent(#{name}, #{desc})`
|
21
|
+
end
|
22
|
+
elsif Browser.supports? 'Event.create'
|
23
|
+
def self.construct(name, desc)
|
24
|
+
%x{
|
25
|
+
var event = document.createEvent("UIEvent");
|
26
|
+
event.initUIEvent(name, desc.bubbles, desc.cancelable,
|
27
|
+
desc.view || window, desc.detail || 0);
|
28
|
+
|
29
|
+
return event;
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end if supported?
|
33
|
+
|
34
|
+
alias_native :detail
|
35
|
+
alias_native :view
|
36
|
+
end
|
37
|
+
|
38
|
+
end; end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Browser; class Event
|
2
|
+
|
3
|
+
class Wheel < UI
|
4
|
+
def self.supported?
|
5
|
+
not $$[:WheelEvent].nil?
|
6
|
+
end
|
7
|
+
|
8
|
+
class Definition < Definition
|
9
|
+
def x=(value)
|
10
|
+
`#@native.deltaX = #{value}`
|
11
|
+
end
|
12
|
+
|
13
|
+
def y=(value)
|
14
|
+
`#@native.deltaY = #{value}`
|
15
|
+
end
|
16
|
+
|
17
|
+
def z=(value)
|
18
|
+
`#@native.deltaZ = #{value}`
|
19
|
+
end
|
20
|
+
|
21
|
+
def mode=(value)
|
22
|
+
value = case value
|
23
|
+
when :pixel then `WheelEvent.DOM_DELTA_PIXEL`
|
24
|
+
when :line then `WheelEvent.DOM_DELTA_LINE`
|
25
|
+
when :page then `WheelEvent.DOM_DELTA_PAGE`
|
26
|
+
end
|
27
|
+
|
28
|
+
`#@native.deltaMode = #{value}`
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.construct(name, desc)
|
33
|
+
`new WheelEvent(#{name}, #{desc})`
|
34
|
+
end
|
35
|
+
|
36
|
+
alias_native :x, :deltaX
|
37
|
+
alias_native :y, :deltaY
|
38
|
+
alias_native :z, :deltaZ
|
39
|
+
|
40
|
+
def mode
|
41
|
+
case `#@native.deltaMode`
|
42
|
+
when `WheelEvent.DOM_DELTA_PIXEL` then :pixel
|
43
|
+
when `WheelEvent.DOM_DELTA_LINE` then :line
|
44
|
+
when `WheelEvent.DOM_DELTA_PAGE` then :page
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end; end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Browser
|
2
|
+
|
3
|
+
# An {EventSource} allows you to receive events from a server in real-time,
|
4
|
+
# similar to long-polling but not exactly.
|
5
|
+
#
|
6
|
+
# @see https://developer.mozilla.org/en-US/docs/Web/API/EventSource
|
7
|
+
class EventSource
|
8
|
+
def self.supported?
|
9
|
+
Browser.supports? :EventSource
|
10
|
+
end
|
11
|
+
|
12
|
+
include Native
|
13
|
+
include Event::Target
|
14
|
+
|
15
|
+
target {|value|
|
16
|
+
EventSource.new(value) if Native.is_a?(value, `window.EventSource`)
|
17
|
+
}
|
18
|
+
|
19
|
+
# Create an {EventSource} on the given path.
|
20
|
+
#
|
21
|
+
# @param path [String] the path to use as source
|
22
|
+
# @yield if the block has no parameters it's instance_exec'd, otherwise it's
|
23
|
+
# called with self
|
24
|
+
def initialize(path, &block)
|
25
|
+
if native?(path)
|
26
|
+
super(path)
|
27
|
+
else
|
28
|
+
super(`new window.EventSource(path)`)
|
29
|
+
end
|
30
|
+
|
31
|
+
if block.arity == 0
|
32
|
+
instance_exec(&block)
|
33
|
+
else
|
34
|
+
block.call(self)
|
35
|
+
end if block
|
36
|
+
end
|
37
|
+
|
38
|
+
# @!attribute [r] url
|
39
|
+
# @return [String] the URL of the event source
|
40
|
+
alias_native :url
|
41
|
+
|
42
|
+
# @!attribute [r] state
|
43
|
+
# @return [:connecting, :open, :closed] the state of the event source
|
44
|
+
def state
|
45
|
+
%x{
|
46
|
+
switch (#@native.readyState) {
|
47
|
+
case window.EventSource.CONNECTING:
|
48
|
+
return "connecting";
|
49
|
+
|
50
|
+
case window.EventSource.OPEN:
|
51
|
+
return "open";
|
52
|
+
|
53
|
+
case window.EventSource.CLOSED:
|
54
|
+
return "closed";
|
55
|
+
}
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
# Check if the event source is alive.
|
60
|
+
def alive?
|
61
|
+
state == :open
|
62
|
+
end
|
63
|
+
|
64
|
+
# Close the event source.
|
65
|
+
def close
|
66
|
+
`#@native.close()`
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'browser/location'
|
2
|
+
|
3
|
+
module Browser
|
4
|
+
|
5
|
+
# {History} allows manipulation of the session history.
|
6
|
+
#
|
7
|
+
# @see https://developer.mozilla.org/en-US/docs/Web/API/History
|
8
|
+
class History
|
9
|
+
# Check if HTML5 history is supported.
|
10
|
+
def self.supported?
|
11
|
+
Browser.supports? 'History'
|
12
|
+
end
|
13
|
+
|
14
|
+
include Native
|
15
|
+
|
16
|
+
# @!attribute [r] length
|
17
|
+
# @return [Integer] how many items are in the history
|
18
|
+
alias_native :length
|
19
|
+
|
20
|
+
# Go back in the history.
|
21
|
+
#
|
22
|
+
# @param number [Integer] how many items to go back
|
23
|
+
def back(number = 1)
|
24
|
+
`#@native.go(-number)`
|
25
|
+
end
|
26
|
+
|
27
|
+
# Go forward in the history.
|
28
|
+
#
|
29
|
+
# @param number [Integer] how many items to go forward
|
30
|
+
def forward(number = 1)
|
31
|
+
`#@native.go(number)`
|
32
|
+
end
|
33
|
+
|
34
|
+
# Push an item in the history.
|
35
|
+
#
|
36
|
+
# @param item [String] the item to push in the history
|
37
|
+
# @param data [Object] additional state to push
|
38
|
+
def push(item, data = nil)
|
39
|
+
data = `null` if data.nil?
|
40
|
+
|
41
|
+
`#@native.pushState(data, null, item)`
|
42
|
+
end
|
43
|
+
|
44
|
+
# Replace the current history item with another.
|
45
|
+
#
|
46
|
+
# @param item [String] the item to replace with
|
47
|
+
# @param data [Object] additional state to replace
|
48
|
+
def replace(item, data = nil)
|
49
|
+
data = `null` if data.nil?
|
50
|
+
|
51
|
+
`#@native.replaceState(data, null, item)`
|
52
|
+
end
|
53
|
+
|
54
|
+
# @!attribute [r] current
|
55
|
+
# @return [String] the current item
|
56
|
+
def current
|
57
|
+
$window.location.path
|
58
|
+
end
|
59
|
+
|
60
|
+
# @!attribute [r] state
|
61
|
+
# @return [Object] the current state
|
62
|
+
if Browser.supports? 'History.state'
|
63
|
+
def state
|
64
|
+
%x{
|
65
|
+
var state = #@native.state;
|
66
|
+
|
67
|
+
if (state == null) {
|
68
|
+
return nil;
|
69
|
+
}
|
70
|
+
else {
|
71
|
+
return state;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
end
|
75
|
+
else
|
76
|
+
def state
|
77
|
+
raise NotImplementedError, 'history state unsupported'
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
class Window
|
83
|
+
# @!attribute [r] history
|
84
|
+
# @return [History] the history for this window
|
85
|
+
def history
|
86
|
+
History.new(`#@native.history`) if `#@native.history`
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|