class DistrictCnSelector::SelectUlSelector
Constants
- BLANK
Public Instance Methods
build_one(type)
click to toggle source
# File lib/district_cn_selector/selector.rb, line 123 def build_one(type) selected_scope = options["selected_#{type}".intern] selected_scopes = options["selected_#{type.to_s.pluralize}".intern] pmt = '' data_value = selected_scope && {:value => selected_scope[1]} || {} data_text = selected_scope && selected_scope[0] || BLANK[type] pmt << content_tag(:span, data_text, :class => "select-content", :data => data_value) pmt << content_tag(:span, "", options[:caret]) opts = '' blank_link = link_to(BLANK[type], "javascript:void(0);") opts << content_tag(:li, blank_link, :class => selected(selected_scope, nil), :data => {:value => ""}) selected_scopes.each do |type| scope_link = link_to type[0], "javascript:void(0);" opts << content_tag(:li, scope_link, :class => selected(type[1], selected_scope && selected_scope[1]), :data => {:value => type[1]}) end prompt_class = { :class => [options[:select_prompt][:class], options[:prompt_class]].join(" ") } prompt = link_to(pmt.html_safe, "javascript:void(0);", options[:select_prompt].merge(prompt_class)) select_options = content_tag(:ul, opts.html_safe, options[:select_options].merge(:style => "max-height:350px;overflow:scroll")) select = prompt + select_options select_class = options[:select][:class] content_tag(:div, select, options[:select].merge(:class => [select_class, type].join(" "))) end
build_select(type)
click to toggle source
# File lib/district_cn_selector/selector.rb, line 92 def build_select(type) content_tag( :div, [build_hidden, public_send("select_#{type}"), javascript_tag].join.html_safe, :class => "#{secure_random}" ) end
javascript_tag()
click to toggle source
# File lib/district_cn_selector/selector.rb, line 100 def javascript_tag javascript = <<-JAVASCRIPT <script> if(window.AREA_SELECT_CN_DISTRICT_UL_FIELDS === undefined) { window.AREA_SELECT_CN_DISTRICT_UL_FIELDS = []; } window.AREA_SELECT_CN_DISTRICT_UL_FIELDS.push( [".#{secure_random}", { selectContainer: '.#{options[:select][:class]}', selectOptsContainer: '.#{options[:select_options][:class]}', selectPromptContainer: '.#{options[:select_prompt][:class]}', onChange: function($container,code){ $container.find(".select-value").val(code); } } ] ); </script> JAVASCRIPT javascript end
options()
click to toggle source
Calls superclass method
# File lib/district_cn_selector/selector.rb, line 75 def options super.merge(theme_options(super)) end
theme_options(opts)
click to toggle source
# File lib/district_cn_selector/selector.rb, line 79 def theme_options(opts) theme = DistrictCnSelector::Theme.district_select_ul theme_options = theme[opts[:theme]] theme_options ||= theme[:default] if opts[:theme].eql?(:bootstrap) && opts[:prompt_class].nil? theme_options[:prompt_class] = "btn" else theme_options[:prompt_class] = opts[:prompt_class] end theme_options end