Module: JsNamespace
- Defined in:
- lib/js_namespace.rb,
lib/js_namespace/version.rb
Constant Summary collapse
- VERSION =
"0.0.2"
Instance Method Summary collapse
- #initialize_javascript ⇒ Object
- #js_action ⇒ Object
- #js_controller ⇒ Object
- #js_page ⇒ Object
- #requires_javascript? ⇒ Boolean
- #site_name ⇒ Object
Instance Method Details
#initialize_javascript ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/js_namespace.rb', line 6 def initialize_javascript javascript_tag(" if (typeof(#{site_name}) !== 'undefined'){ if (typeof(#{site_name}.#{js_controller}) !== 'undefined') { #{site_name}.#{js_controller}.#{js_page}(); } } ") end |
#js_action ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/js_namespace.rb', line 25 def js_action if params[:action] == 'create' 'new' elsif params[:action] == 'update' 'edit' else params[:action] end end |
#js_controller ⇒ Object
21 22 23 |
# File 'lib/js_namespace.rb', line 21 def js_controller params[:controller] + "Controller" end |
#js_page ⇒ Object
35 36 37 |
# File 'lib/js_namespace.rb', line 35 def js_page "#{js_action}Page" end |
#requires_javascript? ⇒ Boolean
17 18 19 |
# File 'lib/js_namespace.rb', line 17 def requires_javascript? false end |
#site_name ⇒ Object
2 3 4 |
# File 'lib/js_namespace.rb', line 2 def site_name 'Site' end |