Module: RightRails::Helpers::Forms::Util
- Defined in:
- lib/right_rails/helpers/forms.rb
Overview
Local utility methods, just hidding the things in here so they didn’t pollute the global scope
Class Method Summary collapse
-
.autocompleter_options(context, options = {}) ⇒ Object
Prepares the autocompleter field options hash.
-
.calendar_options(context, options = {}) ⇒ Object
Prepares a list of options for the calendar widget.
-
.colorpicker_options(context, options) ⇒ Object
Prepares the Colorpicker widget options.
-
.in_rightjs_1 ⇒ Object
Checks if we are in the RightJS 1 mode.
-
.rater_generator(context, name, value, options, method = nil) ⇒ Object
Generates the rater initialization script.
-
.rater_options(context, options) ⇒ Object
Prepares the rater widget options.
-
.require_modules(context, *list) ⇒ Object
Requires RightJS modules in the given context.
-
.rte_options(context, options) ⇒ Object
Prepares the RTE widget options.
-
.slider_generator(context, name, value, options, method = nil) ⇒ Object
Generates the slider initialization script.
-
.slider_options(context, options) ⇒ Object
Prepares the list of slider options.
-
.tags_options(context, options) ⇒ Object
Prepares the Tags widget options.
-
.unit_options(options, unit) ⇒ Object
Preprocesses the RightJS module options.
Class Method Details
.autocompleter_options(context, options = {}) ⇒ Object
Prepares the autocompleter field options hash
192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/right_rails/helpers/forms.rb', line 192 def (context, ={}) require_modules(context, 'autocompleter') [:url] = context.escape_javascript(context.url_for([:url])) url = .delete(:url) if in_rightjs_1 = (, 'autocompleter').merge({:autocomplete => 'off'}) .merge!({:rel => "autocompleter[#{url}]"}) if in_rightjs_1 end |
.calendar_options(context, options = {}) ⇒ Object
Prepares a list of options for the calendar widget
184 185 186 187 |
# File 'lib/right_rails/helpers/forms.rb', line 184 def (context, ={}) require_modules(context, 'calendar') (, 'calendar').merge(in_rightjs_1 ? {:rel => 'calendar'} : {}) end |
.colorpicker_options(context, options) ⇒ Object
Prepares the Colorpicker widget options
248 249 250 251 |
# File 'lib/right_rails/helpers/forms.rb', line 248 def (context, ) require_modules context, 'colorpicker' (, 'colorpicker').merge(in_rightjs_1 ? {:rel => 'colorpicker'} : {}) end |
.in_rightjs_1 ⇒ Object
Checks if we are in the RightJS 1 mode
177 178 179 |
# File 'lib/right_rails/helpers/forms.rb', line 177 def in_rightjs_1 RightRails::Config.rightjs_version < 2 end |
.rater_generator(context, name, value, options, method = nil) ⇒ Object
Generates the rater initialization script
236 237 238 239 240 241 242 243 |
# File 'lib/right_rails/helpers/forms.rb', line 236 def rater_generator(context, name, value, , method=nil) value ||= ActionView::Helpers::InstanceTag.value_before_type_cast( context.instance_variable_get("@#{name}"), method.to_s) if method name = "#{name}[#{method}]" if method id = [:id] || context.send(:sanitize_to_id, name) = RightRails::Helpers.(.merge(:value => value), 'rater') context.javascript_tag "new Rater(#{}).insertTo('#{id}','after').assignTo('#{id}');" end |
.rater_options(context, options) ⇒ Object
Prepares the rater widget options
228 229 230 231 |
# File 'lib/right_rails/helpers/forms.rb', line 228 def (context, ) require_modules context, 'rater' RightRails::Helpers.(, 'rater') end |
.require_modules(context, *list) ⇒ Object
Requires RightJS modules in the given context
163 164 165 |
# File 'lib/right_rails/helpers/forms.rb', line 163 def require_modules(context, *list) RightRails::Helpers.require_js_module context, *list end |
.rte_options(context, options) ⇒ Object
Prepares the RTE widget options
264 265 266 267 |
# File 'lib/right_rails/helpers/forms.rb', line 264 def (context, ) require_modules context, 'rte' (, 'rte') end |
.slider_generator(context, name, value, options, method = nil) ⇒ Object
Generates the slider initialization script
216 217 218 219 220 221 222 223 |
# File 'lib/right_rails/helpers/forms.rb', line 216 def (context, name, value, , method=nil) value ||= ActionView::Helpers::InstanceTag.value_before_type_cast( context.instance_variable_get("@#{name}"), method.to_s ) if method name = "#{name}[#{method}]" if method id = [:id] || context.send(:sanitize_to_id, name) = RightRails::Helpers.(.merge(:value => value), 'slider') context.javascript_tag "new Slider(#{}).insertTo('#{id}','after').assignTo('#{id}');" end |
.slider_options(context, options) ⇒ Object
Prepares the list of slider options
208 209 210 211 |
# File 'lib/right_rails/helpers/forms.rb', line 208 def (context, ) require_modules context, 'dnd', 'slider' RightRails::Helpers.(, 'slider') end |
.tags_options(context, options) ⇒ Object
Prepares the Tags widget options
256 257 258 259 |
# File 'lib/right_rails/helpers/forms.rb', line 256 def (context, ) require_modules context, 'tags' (, 'tags').merge(in_rightjs_1 ? {:rel => 'tags'} : {}) end |
.unit_options(options, unit) ⇒ Object
Preprocesses the RightJS module options
170 171 172 |
# File 'lib/right_rails/helpers/forms.rb', line 170 def (, unit) RightRails::Helpers.(, unit) end |