Module: OpalIrbUtils
- Defined in:
- lib/opal-irb.rb
Class Method Summary collapse
- .include_code_mirror(https = nil) ⇒ Object
-
.include_opal_irb_jqconsole_requirements(opts = { :include_jquery => true, :include_codemirror => true}) ⇒ Object
used to include the requirements in a template file ala <%= OpalIrbUtils.include_opal_irb_jqconsole_requirements %> params opts include a canned version of jquery, jquery-ui, jquery-migrate that is compatibable w/the jqconsole.
- .include_web_jquery ⇒ Object
- .require_scripts(javascripts) ⇒ Object
Class Method Details
.include_code_mirror(https = nil) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/opal-irb.rb', line 37 def self.include_code_mirror(https=nil) prefix = https ? 'https:' : '' cdn = 'cdnjs.cloudflare.com/ajax/libs/codemirror/5.7.0' %|<link rel="stylesheet" href="#{prefix}//#{cdn}/codemirror.css"/>| + require_scripts( [ "#{prefix}//#{cdn}/codemirror.js", "#{prefix}//#{cdn}/keymap/emacs.js", "#{prefix}//#{cdn}/mode/ruby/ruby.js"]) end |
.include_opal_irb_jqconsole_requirements(opts = { :include_jquery => true, :include_codemirror => true}) ⇒ Object
used to include the requirements in a template file ala <%= OpalIrbUtils.include_opal_irb_jqconsole_requirements %> params opts include a canned version of jquery, jquery-ui, jquery-migrate that is compatibable w/the jqconsole. Set this to false if you already include these files params opts include the code mirror
13 14 15 16 17 18 |
# File 'lib/opal-irb.rb', line 13 def self.include_opal_irb_jqconsole_requirements(opts = { :include_jquery => true, :include_codemirror => true}) jquery_scripts = opts[:include_jquery] ? include_web_jquery : "" code_mirror_scripts = opts[:include_codemirror] ? include_code_mirror : "" jquery_scripts + code_mirror_scripts end |
.include_web_jquery ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/opal-irb.rb', line 20 def self.include_web_jquery jquery_requirements = [ "http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js", "https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js", "http://code.jquery.com/jquery-migrate-1.2.1.js" ] # style sheet so editor window has styling '<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />' + require_scripts(jquery_requirements) end |
.require_scripts(javascripts) ⇒ Object
31 32 33 34 35 |
# File 'lib/opal-irb.rb', line 31 def self.require_scripts(javascripts) javascripts.map { |js| "<script src='#{js}'></script>" }.join("\n") end |