vendor/plugins/calendar_date_select/lib/calendar_date_select.rb
# extracts any options passed into calendar date select, appropriating them to either the Javascript call or the html tag.

extracts any options passed into calendar date select, appropriating them to either the Javascript call or the html tag.
extracts any options passed into calendar date select appropriating them to either the Javascript call or the html tag .
def calendar_date_select_process_options(options)
      calendar_options = {}
      callbacks = [:before_show, :before_close, :after_show, :after_close, :after_navigate]
      for key in [:time, :valid_date_check, :embedded, :buttons, :format, :year_range, :month_year, :popup, :hidden, :minute_interval] + callbacks
        calendar_options[key] = options.delete(key) if options.has_key?(key)
      end
      calendar_options[:time] = "'mixed'" if calendar_options[:time].to_s=="mixed"
      calendar_options[:month_year] = "'#{calendar_options[:month_year]}'" if calendar_options[:month_year]
      if calendar_options[:popup].to_s == "force"
        calendar_options[:popup] = "'force'"
        options[:readonly] = true 
      end
      if (vdc=calendar_options.delete(:valid_date_check))
        if vdc.include?(";") || vdc.include?("function")
          throw ":valid_date_check function is missing a 'return' statement.  Try something like: :valid_date_check => 'if (date > new(Date)) return true; else return false;'" unless vdc.include?("return");
        end
        vdc = "return(#{vdc})" unless vdc.include?("return")
        vdc = "function(date) { #{vdc} }" unless vdc.include?("function")
        calendar_options[:valid_date_check] = vdc
      end
      calendar_options[:popup_by] ||= "this" if calendar_options[:hidden]
      for key in callbacks
        calendar_options[key] = "function(param) { #{calendar_options[key]} }" unless calendar_options[key].include?("function") if calendar_options[key]
      end
      calendar_options[:year_range] = format_year_range(calendar_options[:year_range] || 10)
      calendar_options
    end
def calendar_date_select_process_options ( options ) calendar_options = { } callbacks = [ :before_show , :before_close , :after_show , :after_close , :after_navigate ] for key in [ :time , :valid_date_check , :embedded , :buttons , :format , :year_range , :month_year , :popup , :hidden , :minute_interval ] + callbacks calendar_options [ key ] = options . delete ( key ) if options . has_key? ( key ) end calendar_options [ :time ] = "'mixed'" if calendar_options [ :time ] . to_s == "mixed" calendar_options [ :month_year ] = "'#{calendar_options[:month_year]}'" if calendar_options [ :month_year ] if calendar_options [ :popup ] . to_s == "force" calendar_options [ :popup ] = "'force'" options [ :readonly ] = true end if ( vdc = calendar_options . delete ( :valid_date_check ) ) if vdc . include? ( ";" ) || vdc . include? ( "function" ) throw ":valid_date_check function is missing a 'return' statement.  Try something like: :valid_date_check => 'if (date > new(Date)) return true; else return false;'" unless vdc . include? ( "return" ) ; end vdc = "return(#{vdc})" unless vdc . include? ( "return" ) vdc = "function(date) { #{vdc} }" unless vdc . include? ( "function" ) calendar_options [ :valid_date_check ] = vdc end calendar_options [ :popup_by ] ||= "this" if calendar_options [ :hidden ] for key in callbacks calendar_options [ key ] = "function(param) { #{calendar_options[key]} }" unless calendar_options [ key ] . include? ( "function" ) if calendar_options [ key ] end calendar_options [ :year_range ] = format_year_range ( calendar_options [ :year_range ] || 10 ) calendar_options end
extracts any options passed into calendar date select, appropriating them to either the Javascript call or the html tag.
extracts any options passed into calendar date select appropriating them to either the Javascript call or the html tag .
# if passing in mixed, pad it with single quotes
 # if we are forcing the popup, automatically set the readonly property on the input control.
 # surround any callbacks with a function, if not already done so

options