File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 1+ class Helper
2+ def initialize ( window )
3+ @navigator = window . navigator
4+ end
5+
6+ def ios?
7+ @navigator . user_agent &.match? ( /\b (iPad|iPhone|iPod)\b / )
8+ end
9+
10+ def macos?
11+ @navigator . user_agent &.match? ( /\b Mac\b / )
12+ end
13+ end
Original file line number Diff line number Diff line change 44require 'editor'
55require 'lesson'
66require 'ruby_engine'
7+ require 'helper'
78
89# The TryRuby application
910class TryRuby
@@ -32,7 +33,7 @@ def initialize
3233 @current_item = nil
3334 @current_copycode = nil
3435 @updating = false
35- @navigator = $window. navigator
36+ @helper = Helper . new ( $window)
3637
3738 initialize_menu
3839
@@ -62,8 +63,7 @@ def initialize
6263
6364 #If hold down the control and the Enter key goes down, run
6465 $document. on :keydown , '#editor' do |e |
65- if e . key == "Enter" && ( ( e . ctrl? && !@navigator . user_agent &.match? ( /\b (iPad|iPhone|iPod)\b / ) ) ||
66- ( @navigator . user_agent &.match? ( /\b (Mac|iPad|iPhone|iPod)\b / ) && e . meta? ) )
66+ if e . key == "Enter" && ( ( e . ctrl? && !@helper . ios? ) || ( ( @helper . macos? || @helper . ios? ) && e . meta? ) )
6767 e . prevent
6868 do_run
6969 end
You can’t perform that action at this time.
0 commit comments