Class: Daru::View::DataTables
- Inherits:
-
Object
- Object
- Daru::View::DataTables
- Defined in:
- lib/daru/data_tables/display/display.rb,
lib/daru/data_tables/display/iruby_notebook.rb
Class Method Summary collapse
-
.init_css(dependent_css = DATATABLES_DEPENDENCIES_CSS) ⇒ String
CSS code of the dependent file(s).
-
.init_iruby(dependent_js = DATATABLES_DEPENDENCIES_IRUBY) ⇒ Object
Enable to show plots on IRuby notebook.
-
.init_javascript(dependent_js = DATATABLES_DEPENDENCIES_WEB) ⇒ String
Js code of the dependent files.
-
.init_script ⇒ String
dependent script for the library.
Class Method Details
.init_css(dependent_css = DATATABLES_DEPENDENCIES_CSS) ⇒ String
Returns CSS code of the dependent file(s).
27 28 29 30 31 32 33 34 35 |
# File 'lib/daru/data_tables/display/display.rb', line 27 def self.init_css( dependent_css=DATATABLES_DEPENDENCIES_CSS ) css = '' css << "\n<style type='text/css'>" css << Daru::View.generate_init_code_css(dependent_css) css << "\n</style>" css end |
.init_iruby(dependent_js = DATATABLES_DEPENDENCIES_IRUBY) ⇒ Object
Enable to show plots on IRuby notebook. Load the dependent JS files in IRuby notebook. Those JS will help in plotting the table in IRuby cell.
One can see the loaded JS files in the source code of the notebook. DataTables.init_iruby
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/daru/data_tables/display/iruby_notebook.rb', line 34 def self.init_iruby( dependent_js=DATATABLES_DEPENDENCIES_IRUBY ) # dependent_css=['jquery.dataTables.css'] # Note: Jquery is dependecy for DataTables. # Since Jquery is already a dependency for iruby notebook. # So it will be loaded into IRuby notebook when `iruby` is run. # No need to add it in the `dependent_js`. js = generate_init_code_js(dependent_js) # TODO: don't know how to import css like js # css = generate_init_code_css(dependent_css) IRuby.display(IRuby.javascript(js)) # IRuby.display(css, mime: 'text/stylesheet') # FixMe: Don't know, how to add css in IRuby notebook (Means there is # no IRuby.stylesheet(..) method) end |
.init_javascript(dependent_js = DATATABLES_DEPENDENCIES_WEB) ⇒ String
Returns js code of the dependent files.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/daru/data_tables/display/display.rb', line 13 def self.init_javascript( dependent_js=DATATABLES_DEPENDENCIES_WEB ) # TODO: there are many js and css files, that must be added for # more features. Refer: https://datatables.net/download/index js = '' js << "\n<script type='text/javascript'>" js << Daru::View.generate_init_code_js(dependent_js) js << "\n</script>" js end |
.init_script ⇒ String
dependent script for the library. It must be added in the head tag of the web application.
dep_js = DataTables.init_script
use in Rails app : <%=raw dep_js %>
46 47 48 49 50 51 |
# File 'lib/daru/data_tables/display/display.rb', line 46 def self.init_script init_code = '' init_code << init_css init_code << init_javascript init_code end |