Class: Waw::Routing::Feedback

Inherits:
RoutingRule show all
Defined in:
lib/waw/routing/feedback.rb

Overview

Feedback routing

Instance Method Summary collapse

Methods inherited from RoutingRule

#apply_on_browser

Constructor Details

#initialize(opts = {}) ⇒ Feedback

Creates a feedback instance



7
8
9
# File 'lib/waw/routing/feedback.rb', line 7

def initialize(opts = {})
  @opts = opts
end

Instance Method Details

#generate_js_code(result, align = 0) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/waw/routing/feedback.rb', line 11

def generate_js_code(result, align=0)
  selector = @opts[:css_selector] || '.feedback'
  buffer = ""
  buffer << " "*align + "$(form + ' input').hide();\n" if @opts[:hide_input]
  buffer << " "*align + "$(form + ' #{selector}').show();\n"
  message = @opts[:message] ? "'#{@opts[:message]}'" : 'data[1][0]'
  buffer << " "*align + "$(form + ' #{selector}').html(messages[#{message}]);"
  buffer
end