compass-jquery-plugin 0.3.0.beta.21 → 0.3.0.beta.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. data/README.textile +212 -211
  2. data/VERSION.yml +5 -5
  3. data/compass-jquery-plugin.gemspec +25 -2
  4. data/gem_tasks/jqtouch.rake +221 -201
  5. data/gem_tasks/jrails.rake +322 -311
  6. data/lib/compiler.jar +0 -0
  7. data/lib/jquery/flash_messages.rb +45 -45
  8. data/lib/jquery/gridify/grid.rb +147 -147
  9. data/lib/jquery/gridify/grid_column.rb +134 -134
  10. data/lib/jquery/gridify/grid_finder.rb +223 -211
  11. data/lib/jquery/gridify/grid_options.rb +279 -279
  12. data/lib/jquery/gridify/grid_view.rb +435 -436
  13. data/lib/jquery/gridify.rb +42 -42
  14. data/templates/dynatree/jquery.dynatree.min.js +1 -1
  15. data/templates/jqgrid/i18n/jqgrid/locale-bg.min.js +6 -15
  16. data/templates/jqgrid/i18n/jqgrid/locale-bg1251.min.js +6 -15
  17. data/templates/jqgrid/i18n/jqgrid/locale-cat.min.js +5 -6
  18. data/templates/jqgrid/i18n/jqgrid/locale-cn.min.js +5 -8
  19. data/templates/jqgrid/i18n/jqgrid/locale-cs.min.js +6 -8
  20. data/templates/jqgrid/i18n/jqgrid/locale-da.min.js +6 -6
  21. data/templates/jqgrid/i18n/jqgrid/locale-de.min.js +7 -7
  22. data/templates/jqgrid/i18n/jqgrid/locale-el.min.js +7 -13
  23. data/templates/jqgrid/i18n/jqgrid/locale-es.min.js +7 -7
  24. data/templates/jqgrid/i18n/jqgrid/locale-fa.min.js +6 -12
  25. data/templates/jqgrid/i18n/jqgrid/locale-fr.min.js +7 -7
  26. data/templates/jqgrid/i18n/jqgrid/locale-gl.min.js +7 -7
  27. data/templates/jqgrid/i18n/jqgrid/locale-he.min.js +6 -13
  28. data/templates/jqgrid/i18n/jqgrid/locale-hu.min.js +6 -8
  29. data/templates/jqgrid/i18n/jqgrid/locale-is.min.js +6 -7
  30. data/templates/jqgrid/i18n/jqgrid/locale-it.min.js +4 -4
  31. data/templates/jqgrid/i18n/jqgrid/locale-ja.min.js +5 -10
  32. data/templates/jqgrid/i18n/jqgrid/locale-no.min.js +6 -6
  33. data/templates/jqgrid/i18n/jqgrid/locale-pl.min.js +6 -7
  34. data/templates/jqgrid/i18n/jqgrid/locale-pt-br.min.js +6 -7
  35. data/templates/jqgrid/i18n/jqgrid/locale-pt.min.js +4 -5
  36. data/templates/jqgrid/i18n/jqgrid/locale-ro.min.js +7 -8
  37. data/templates/jqgrid/i18n/jqgrid/locale-ru.min.js +7 -16
  38. data/templates/jqgrid/i18n/jqgrid/locale-sk.min.js +6 -8
  39. data/templates/jqgrid/i18n/jqgrid/locale-sv.min.js +6 -7
  40. data/templates/jqgrid/i18n/jqgrid/locale-tr.min.js +6 -7
  41. data/templates/jqgrid/i18n/jqgrid/locale-ua.min.js +7 -16
  42. data/templates/jqgrid/jquery.jqGrid.js +11567 -11565
  43. data/templates/jqgrid/jquery.jqGrid.min.js +472 -472
  44. data/templates/jqical/jquery.jqical.js +5 -9
  45. data/templates/jqical/jquery.jqical.min.js +44 -44
  46. data/templates/jqical/jquery.ui/jqical.scss +1 -1
  47. data/templates/jqtouch/config/initializers/jqtouch.rb +5 -4
  48. data/templates/jqtouch/jqtouch/apple/activeButton.png +0 -0
  49. data/templates/jqtouch/jqtouch/default/backButton.png +0 -0
  50. data/templates/jqtouch/jqtouch/default/backButtonActive.png +0 -0
  51. data/templates/jqtouch/jqtouch/default/bigButton.png +0 -0
  52. data/templates/jqtouch/jqtouch/default/bigButtonActive.png +0 -0
  53. data/templates/jqtouch/jqtouch/default/button.png +0 -0
  54. data/templates/jqtouch/jqtouch/default/buttonActive.png +0 -0
  55. data/templates/jqtouch/jqtouch/default/chevron.png +0 -0
  56. data/templates/jqtouch/jqtouch/default/chevronActive.png +0 -0
  57. data/templates/jqtouch/jqtouch/default/chevronCircle.png +0 -0
  58. data/templates/jqtouch/jqtouch/default/chevronCircleActive.png +0 -0
  59. data/templates/jqtouch/jqtouch/default/loading.gif +0 -0
  60. data/templates/jqtouch/jqtouch/default/toggleSwitch.png +0 -0
  61. data/templates/jqtouch/jqtouch/default/toolbarBackground.png +0 -0
  62. data/templates/jqtouch/jqtouch/jqt/back_button_clicked.png +0 -0
  63. data/templates/jqtouch/jqtouch/jqt.apple.scss +24 -11
  64. data/templates/jqtouch/jqtouch/jqt.default.scss +537 -0
  65. data/templates/jqtouch/jqtouch/jqt.jqt.scss +20 -6
  66. data/templates/jqtouch/jqtouch/jqtouch.scss +173 -1
  67. data/templates/jqtouch/jqtouch/photo/btnBack.png +0 -0
  68. data/templates/jqtouch/jqtouch/photo/loading.gif +0 -0
  69. data/templates/jqtouch/jqtouch/photo/navNext.png +0 -0
  70. data/templates/jqtouch/jqtouch/photo/navPause.png +0 -0
  71. data/templates/jqtouch/jqtouch/photo/navPlay.png +0 -0
  72. data/templates/jqtouch/jqtouch/photo/navPrev.png +0 -0
  73. data/templates/jqtouch/jqtouch/photo/toolbar.png +0 -0
  74. data/templates/jqtouch/jquery.jqtouch.js +8219 -632
  75. data/templates/jqtouch/jquery.jqtouch.min.js +60 -1
  76. data/templates/jqtouch/manifest.rb +21 -0
  77. data/templates/jrails/config/initializers/jrails.rb +1 -0
  78. data/templates/jrails/haml.js +2 -2
  79. data/templates/jrails/i18n/jquery.ui/datepicker-ar.min.js +2 -4
  80. data/templates/jrails/i18n/jquery.ui/datepicker-az.min.js +2 -2
  81. data/templates/jrails/i18n/jquery.ui/datepicker-bg.min.js +2 -4
  82. data/templates/jrails/i18n/jquery.ui/datepicker-bs.min.js +2 -2
  83. data/templates/jrails/i18n/jquery.ui/datepicker-cs.min.js +2 -2
  84. data/templates/jrails/i18n/jquery.ui/datepicker-da.min.js +2 -2
  85. data/templates/jrails/i18n/jquery.ui/datepicker-de.min.js +2 -2
  86. data/templates/jrails/i18n/jquery.ui/datepicker-el.min.js +2 -4
  87. data/templates/jrails/i18n/jquery.ui/datepicker-eo.min.js +2 -2
  88. data/templates/jrails/i18n/jquery.ui/datepicker-et.min.js +2 -2
  89. data/templates/jrails/i18n/jquery.ui/datepicker-fa.min.js +2 -3
  90. data/templates/jrails/i18n/jquery.ui/datepicker-fo.min.js +2 -2
  91. data/templates/jrails/i18n/jquery.ui/datepicker-fr-CH.min.js +2 -2
  92. data/templates/jrails/i18n/jquery.ui/datepicker-fr.min.js +2 -2
  93. data/templates/jrails/i18n/jquery.ui/datepicker-he.min.js +2 -3
  94. data/templates/jrails/i18n/jquery.ui/datepicker-hr.min.js +2 -2
  95. data/templates/jrails/i18n/jquery.ui/datepicker-hu.min.js +2 -2
  96. data/templates/jrails/i18n/jquery.ui/datepicker-hy.min.js +2 -4
  97. data/templates/jrails/i18n/jquery.ui/datepicker-ja.min.js +2 -2
  98. data/templates/jrails/i18n/jquery.ui/datepicker-ko.min.js +2 -2
  99. data/templates/jrails/i18n/jquery.ui/datepicker-kz.min.js +2 -4
  100. data/templates/jrails/i18n/jquery.ui/datepicker-lt.min.js +2 -2
  101. data/templates/jrails/i18n/jquery.ui/datepicker-lv.min.js +2 -2
  102. data/templates/jrails/i18n/jquery.ui/datepicker-nl.min.js +2 -2
  103. data/templates/jrails/i18n/jquery.ui/datepicker-no.min.js +2 -2
  104. data/templates/jrails/i18n/jquery.ui/datepicker-pl.min.js +2 -2
  105. data/templates/jrails/i18n/jquery.ui/datepicker-ro.min.js +2 -2
  106. data/templates/jrails/i18n/jquery.ui/datepicker-ru.min.js +2 -4
  107. data/templates/jrails/i18n/jquery.ui/datepicker-sk.min.js +2 -2
  108. data/templates/jrails/i18n/jquery.ui/datepicker-sq.min.js +2 -2
  109. data/templates/jrails/i18n/jquery.ui/datepicker-sr-SR.min.js +2 -2
  110. data/templates/jrails/i18n/jquery.ui/datepicker-sr.min.js +2 -4
  111. data/templates/jrails/i18n/jquery.ui/datepicker-sv.min.js +2 -2
  112. data/templates/jrails/i18n/jquery.ui/datepicker-ta.min.js +2 -4
  113. data/templates/jrails/i18n/jquery.ui/datepicker-th.min.js +2 -4
  114. data/templates/jrails/i18n/jquery.ui/datepicker-tr.min.js +2 -2
  115. data/templates/jrails/i18n/jquery.ui/datepicker-uk.min.js +2 -4
  116. data/templates/jrails/i18n/jquery.ui/datepicker-vi.min.js +2 -2
  117. data/templates/jrails/i18n/jquery.ui/datepicker-zh-CN.min.js +2 -2
  118. data/templates/jrails/i18n/jquery.ui/datepicker-zh-HK.min.js +2 -2
  119. data/templates/jrails/i18n/jquery.ui/datepicker-zh-TW.min.js +2 -2
  120. data/templates/jrails/jquery-1.4.2.min.js +156 -156
  121. data/templates/jrails/jquery-ui-1.8.5.js +23753 -23341
  122. data/templates/jrails/jquery-ui-1.8.5.min.js +823 -808
  123. data/templates/jrails/jquery.contextMenu.min.js +1 -1
  124. data/templates/jrails/jquery.sparkline.js +1050 -0
  125. data/templates/jrails/jquery.sparkline.min.js +31 -0
  126. data/templates/jrails/jquery.ui/_theme.scss +1699 -1634
  127. data/templates/jrails/manifest.rb +13 -11
  128. data/templates/jstree/jquery.jstree.min.js +10 -10
  129. data/templates/ribbon/jquery.ribbon.min.js +6 -6
  130. metadata +27 -4
data/lib/compiler.jar CHANGED
Binary file
@@ -1,45 +1,45 @@
1
- module FlashMessages
2
- module ControllerMethods
3
- TYPES = [:success, :notice, :warning, :error]
4
-
5
- TYPES.each do |type|
6
- define_method(type) do |msg|
7
- flash[type] = msg
8
- end
9
-
10
- define_method("#{type}_now") do |msg|
11
- flash.now[type] = msg
12
- end
13
- end
14
- end
15
-
16
- module Display
17
- # def flash_messages
18
- # returning html = String.new do
19
- # flash.each do |css_class, message|
20
- # html << content_tag(:div, content_tag(:div, nil, :class => :icon) + message, :class => css_class)
21
- # end
22
- # end
23
- # end
24
-
25
- FLASH_NOTICE_KEYS = [:error, :warning, :notice, :success]
26
-
27
- def flash_messages
28
- return unless messages = flash.keys.select{|k| FLASH_NOTICE_KEYS.include?(k)}
29
- formatted_messages = messages.map do |type|
30
- content_tag(:div, nil, :class => type.to_s) do
31
- message_for_item(flash[type], flash["#{type}_item".to_sym])
32
- end
33
- end
34
- formatted_messages.join
35
- end
36
-
37
- def message_for_item(message, item = nil)
38
- if item.is_a?(Array)
39
- content_tag(:div, nil, :class => :icon) + message % link_to(*item)
40
- else
41
- content_tag(:div, nil, :class => :icon) + message % item
42
- end
43
- end
44
- end
45
- end
1
+ module FlashMessages
2
+ module ControllerMethods
3
+ TYPES = [:success, :notice, :warning, :error]
4
+
5
+ TYPES.each do |type|
6
+ define_method(type) do |msg|
7
+ flash[type] = msg
8
+ end
9
+
10
+ define_method("#{type}_now") do |msg|
11
+ flash.now[type] = msg
12
+ end
13
+ end
14
+ end
15
+
16
+ module Display
17
+ # def flash_messages
18
+ # returning html = String.new do
19
+ # flash.each do |css_class, message|
20
+ # html << content_tag(:div, content_tag(:div, nil, :class => :icon) + message, :class => css_class)
21
+ # end
22
+ # end
23
+ # end
24
+
25
+ FLASH_NOTICE_KEYS = [:error, :warning, :notice, :success]
26
+
27
+ def flash_messages
28
+ return unless messages = flash.keys.select{|k| FLASH_NOTICE_KEYS.include?(k)}
29
+ formatted_messages = messages.map do |type|
30
+ content_tag(:div, nil, :class => type.to_s + " ui-corner-all") do
31
+ message_for_item(flash[type], flash["#{type}_item".to_sym])
32
+ end
33
+ end
34
+ formatted_messages.join
35
+ end
36
+
37
+ def message_for_item(message, item = nil)
38
+ if item.is_a?(Array)
39
+ content_tag(:div, nil, :class => :icon) + message % link_to(*item)
40
+ else
41
+ content_tag(:div, nil, :class => :icon) + message % item
42
+ end
43
+ end
44
+ end
45
+ end
@@ -1,147 +1,147 @@
1
- require 'jquery/gridify/assertions'
2
- require 'jquery/gridify/grid_options'
3
- require 'jquery/gridify/grid_view'
4
- require 'jquery/gridify/grid_column'
5
- require 'jquery/gridify/grid_finder'
6
-
7
- # NOTE: for readablity/clarity, native jqGrid options should be string; Ruby ones as syms
8
-
9
- module Gridify
10
- class Grid
11
- include Assertions
12
-
13
- # todo: change this so klass is optional, decouple from active record
14
- def initialize( klass, *args, &block )
15
- #debugger
16
- options = args.extract_options! # => args.last.is_a?(Hash) ? args.pop : {}
17
- assert_exclusive_keys( options, :only, :except)
18
-
19
- @resource = klass.to_s.tableize.pluralize
20
- @name = args.first || :grid
21
-
22
- # non-persistent options
23
- # generate model unless explicitly say no
24
- build_model = options.delete(:build_model) == false ? false : true
25
- only = options.delete(:only)
26
- except = options.delete(:except)
27
- col_presets = options.delete(:colModel)
28
-
29
- # assign options
30
- update options
31
-
32
- # build columns from ActiveRecord model (klass)
33
- if klass.present? && build_model
34
- @model = build_columns klass, only, except, col_presets
35
- end
36
-
37
- instance_eval(&block) if block
38
- #(note instance_eval cannot access things outside its scope; otherwise do this:
39
- #yield self if block_given?
40
- end
41
-
42
- def update( options )
43
- options.each {|atr, val| send( "#{atr}=", val )}
44
- # exception "invalid option..."
45
- end
46
-
47
- def column( name, options={} )
48
- name = name.to_s
49
- klass = resource.classify.constantize
50
- # TODO: set edit options based on ar_column
51
- # TODO: edit
52
- # TODO: handle file input types
53
- # TODO: custom input types
54
- if col = columns_hash[name]
55
- # update an existing column
56
- col.update options
57
-
58
- elsif ar = klass.columns.detect {|c| c.name==name}
59
- #debugger
60
- # create column from database schema
61
- edit = editable &&
62
- # only edit accessible attributes
63
- (klass.accessible_attributes.nil? || klass.accessible_attributes.include?(ar.name))
64
- args = {
65
- :ar_column => ar,
66
- :name => ar.name,
67
- :value_type => ar.type,
68
- :searchable => searchable,
69
- :sortable => sortable,
70
- :editable => edit
71
- }.merge(options)
72
- colModel << GridColumn.new( args)
73
-
74
- else
75
- # create column from scratch
76
- args = {
77
- :name => name,
78
- :value_type => :string,
79
- :searchable => searchable,
80
- :sortable => sortable,
81
- :editable => edit
82
- }.merge(options)
83
- colModel << GridColumn.new( args)
84
- end
85
- end
86
-
87
- def column_names
88
- colModel.collect {|col| col.name.titleize }
89
- end
90
-
91
- def column_model
92
- colModel.collect {|col| col.properties }
93
- end
94
-
95
- # normally we need to keep columns an ordered array, sometimes its convenient to have a hash
96
- def columns_hash
97
- colModel.inject({}) {|h, col| h[col.name] = col; h }
98
- end
99
-
100
- protected
101
-
102
- # # isnt there something in rails to do this already?
103
- # def parse_options( keys, options )
104
- # ops = keys.inject({}) do |h, k|
105
- # val = options.delete(k)
106
- # h[k] = val unless val.nil?
107
- # h
108
- # end
109
- # ops || {}
110
- # end
111
-
112
- # generate list of columns based on AR model
113
- # option: :only or :except
114
- # :col_options hash of hash of preset values for columns (eg from cookie) { :title => {:width => 98}}
115
- def build_columns( klass, only, except, presets )
116
- #debugger
117
- # stringify
118
- only = Array(only).map {|s| s.to_s }
119
- except = Array(except).map {|s| s.to_s }
120
- presets ||= {}
121
- presets.stringify_keys!
122
-
123
- self.colModel = klass.columns.collect do |ar|
124
- #debugger
125
- next if only.present? && !only.include?(ar.name)
126
- next if except.present? && except.include?(ar.name)
127
- is_key = (ar.name=='id')
128
- edit = editable && !is_key &&
129
- # only edit accessible attributes
130
- (klass.accessible_attributes.nil? || klass.accessible_attributes.include?(ar.name))
131
- args = {
132
- :ar_column => ar,
133
- :name => ar.name,
134
- :value_type => ar.type,
135
- :key => is_key,
136
- #:hidden => is_key,
137
- :searchable => searchable,
138
- :sortable => sortable,
139
- :editable => edit
140
- }
141
-
142
- # create column with default args merged with options given for this column
143
- GridColumn.new args.merge( presets[ar.name]||{} )
144
- end.compact
145
- end
146
- end
147
- end
1
+ require 'jquery/gridify/assertions'
2
+ require 'jquery/gridify/grid_options'
3
+ require 'jquery/gridify/grid_view'
4
+ require 'jquery/gridify/grid_column'
5
+ require 'jquery/gridify/grid_finder'
6
+
7
+ # NOTE: for readablity/clarity, native jqGrid options should be string; Ruby ones as syms
8
+
9
+ module Gridify
10
+ class Grid
11
+ include Assertions
12
+
13
+ # todo: change this so klass is optional, decouple from active record
14
+ def initialize( klass, *args, &block )
15
+ #debugger
16
+ options = args.extract_options! # => args.last.is_a?(Hash) ? args.pop : {}
17
+ assert_exclusive_keys( options, :only, :except)
18
+
19
+ @resource = klass.to_s.tableize.pluralize
20
+ @name = args.first || :grid
21
+
22
+ # non-persistent options
23
+ # generate model unless explicitly say no
24
+ build_model = options.delete(:build_model) == false ? false : true
25
+ only = options.delete(:only)
26
+ except = options.delete(:except)
27
+ col_presets = options.delete(:colModel)
28
+ col_include = options[:colInclude]
29
+
30
+ # assign options
31
+ update options
32
+
33
+ # build columns from ActiveRecord model (klass)
34
+ if klass.present? && build_model
35
+ @model = build_columns(klass, only, except, col_presets, col_include)
36
+ end
37
+
38
+ instance_eval(&block) if block
39
+ #(note instance_eval cannot access things outside its scope; otherwise do this:
40
+ #yield self if block_given?
41
+ end
42
+
43
+ def update( options )
44
+ options.each {|atr, val| send( "#{atr}=", val )}
45
+ # exception "invalid option..."
46
+ end
47
+
48
+ def column( name, options={} )
49
+ name = name.to_s
50
+ klass = resource.classify.constantize
51
+ # TODO: set edit options based on ar_column
52
+ # TODO: edit
53
+ # TODO: handle file input types
54
+ # TODO: custom input types
55
+ if col = columns_hash[name]
56
+ # update an existing column
57
+ col.update options
58
+
59
+ elsif ar = klass.columns.detect {|c| c.name==name}
60
+ #debugger
61
+ # create column from database schema
62
+ edit = editable &&
63
+ # only edit accessible attributes
64
+ (klass.accessible_attributes.nil? || klass.accessible_attributes.include?(ar.name))
65
+ args = {
66
+ :ar_column => ar,
67
+ :name => ar.name,
68
+ :value_type => ar.type,
69
+ :searchable => searchable,
70
+ :sortable => sortable,
71
+ :editable => edit
72
+ }.merge(options)
73
+ colModel << GridColumn.new( args)
74
+
75
+ else
76
+ # create column from scratch
77
+ args = {
78
+ :name => name,
79
+ :value_type => :string,
80
+ :searchable => searchable,
81
+ :sortable => sortable,
82
+ :editable => edit
83
+ }.merge(options)
84
+ colModel << GridColumn.new( args)
85
+ end
86
+ end
87
+
88
+ def column_names
89
+ colModel.collect {|col| col.name.titleize }
90
+ end
91
+
92
+ def column_model
93
+ colModel.collect {|col| col.properties }
94
+ end
95
+
96
+ # normally we need to keep columns an ordered array, sometimes its convenient to have a hash
97
+ def columns_hash
98
+ colModel.inject({}) {|h, col| h[col.name] = col; h }
99
+ end
100
+
101
+ protected
102
+
103
+ # # isnt there something in rails to do this already?
104
+ # def parse_options( keys, options )
105
+ # ops = keys.inject({}) do |h, k|
106
+ # val = options.delete(k)
107
+ # h[k] = val unless val.nil?
108
+ # h
109
+ # end
110
+ # ops || {}
111
+ # end
112
+
113
+ # generate list of columns based on AR model
114
+ # option: :only or :except
115
+ # :col_options hash of hash of preset values for columns (eg from cookie) { :title => {:width => 98}}
116
+ def build_columns( klass, only, except, presets, col_include )
117
+ #debugger
118
+ # stringify
119
+ only = Array(only).map {|s| s.to_s }
120
+ except = Array(except).map {|s| s.to_s }
121
+ presets ||= {}
122
+ presets.stringify_keys!
123
+
124
+ self.colModel = klass.columns.collect do |ar|
125
+ #debugger
126
+ next if only.present? && !only.include?(ar.name)
127
+ next if except.present? && except.include?(ar.name)
128
+ is_key = (ar.name=='id')
129
+ edit = editable && !is_key &&
130
+ # only edit accessible attributes
131
+ (klass.accessible_attributes.nil? || klass.accessible_attributes.include?(ar.name))
132
+ args = {
133
+ :ar_column => ar,
134
+ :name => ar.name,
135
+ :value_type => ar.type,
136
+ :key => is_key,
137
+ #:hidden => is_key,
138
+ :searchable => searchable,
139
+ :sortable => sortable,
140
+ :editable => edit
141
+ }
142
+ # create column with default args merged with options given for this column
143
+ GridColumn.new args.merge( presets[ar.name]||{} )
144
+ end.compact
145
+ end
146
+ end
147
+ end
@@ -1,134 +1,134 @@
1
- module Gridify
2
- class GridColumn
3
-
4
- attr_accessor :name, # attribute name (required)
5
- :label,
6
- :ar_column, # active_record column
7
- :value_type, # active_record data type :string, :text, :integer, :float, :boolean, + :currency
8
- :key, # true if this is the key (only :id)
9
-
10
- # column formatting
11
- :width, # initial width (150)
12
- :fixed_width, # true = not resized when recalc fit to width
13
- :formatter, # see jqGrid doc (based on value_type)
14
- :format_options, # hash, see jqGrid doc (based on value_type)
15
- :align, # 'left', 'right', 'center' (left for strings, right for numerics)
16
- #:classes, # optional classes to add to column
17
-
18
- # column actions
19
- :resizable, # t/f (true)
20
- :sortable, # t/f (true) or jqGrid sorttype: :integer, :float, :currency, :date, :text (true)
21
- :searchable, # true/false (true) or text or select
22
- #:search_options,
23
- :editable, # true/false (false),
24
- :edit_type, # text, textarea, select, checkbox, password, button, image and file (based on value_type)
25
- :edit_options, # html input field options, depends on editable type (eg {"size" => 10, "maxlength" => 15}) see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:common_rules
26
- :validations, # jqGrid editrules (TODO derive from AR model validations) see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:common_rules
27
- # "required" "integer" "email" "url" etc
28
- :form_options, # jqGrid formoptions for formatting input forms
29
- # select types
30
- #:select_url, # url to dynamically get select options
31
-
32
- # visiblity
33
- #:always_hidden, # (false)
34
- :sorttype,
35
- :summary_type,
36
- :summary_tpl,
37
- :hidden # initial hide state (false)
38
-
39
- def initialize(options)
40
- update options
41
- end
42
-
43
- def update(options)
44
- options.each {|atr, val| send( "#{atr}=", val )}
45
- end
46
-
47
- def to_json
48
- properties.to_json #_with_js
49
- end
50
-
51
- def properties
52
- jqgrid_properties
53
- end
54
-
55
- def resizable
56
- if @resizable==false
57
- false
58
- else
59
- # true or nil
60
- true
61
- end
62
- end
63
-
64
- def fixed_width
65
- if @fixed_width==false
66
- false
67
- elsif @fixed_width.nil?
68
- !resizable
69
- else
70
- @fixed_width
71
- end
72
- end
73
-
74
- # ----------------
75
- private
76
-
77
- def jqgrid_type
78
- return sortable unless sortable==true
79
- case value_type
80
- when :string : 'text'
81
- when :text : 'text'
82
- when :integer : 'integer'
83
- when :float : 'float'
84
- when :boolean : 'boolean'
85
- when :datetime : 'date'
86
- end
87
- end
88
-
89
- # note, we dont vals[:foo] = foo because dont want to bother generating key if its same as jqGrid default
90
- def jqgrid_properties
91
- vals = {
92
- :name => name,
93
- :index => name
94
- }
95
- #xmlmap not required when same as :name
96
- # vals[:xmlmap] = name if data_type == :xml
97
- # vals[:jsonmap] = name if data_type == :json
98
-
99
- vals[:label] = label || name.titleize
100
- vals[:resizable] = false if resizable==false
101
- vals[:fixed] = fixed_width unless fixed_width==false
102
- vals[:sortable] = false if sortable==false
103
- vals[:sorttype] = jqgrid_type if sortable
104
- vals[:search] = false if searchable==false
105
- vals[:editable] = true if editable
106
- vals[:align] = align if align
107
- #vals[:align] = 'right' if [:integer, :float, :currency].include?(value_type)
108
- case value_type
109
- when :datetime
110
- vals[:formatter] = 'date'
111
- vals[:formatoptions] = { :srcformat => 'UniversalSortableDateTime', :newformat => 'FullDateTime' }
112
- end
113
- vals[:hidden] = true if hidden
114
- vals[:width] = width if width
115
- vals[:formatter] = formatter if formatter
116
- vals[:formatoptions] = format_options if format_options
117
- vals[:edittype] = edit_type if editable && edit_type
118
- vals[:formoptions] = form_options if editable && form_options
119
- vals[:editoptions] = edit_options if editable && edit_options
120
- vals[:editrules] = validations if editable && validations
121
-
122
- vals[:sorttype] = sorttype if sorttype
123
- vals[:summaryType] = summary_type if summary_type
124
- vals[:summaryTpl] = summary_tpl if summary_tpl
125
- # and more...
126
-
127
- vals
128
- end
129
-
130
- end
131
- end
132
-
133
- #<ActiveRecord::ConnectionAdapters::SQLiteColumn:0x2515a98 @sql_type="varchar(255)", @name="title", @precision=nil, @primary=false, @default=nil, @limit=255, @null=true, @type=:string, @scale=nil>
134
-
1
+ module Gridify
2
+ class GridColumn
3
+
4
+ attr_accessor :name, # attribute name (required)
5
+ :label,
6
+ :ar_column, # active_record column
7
+ :value_type, # active_record data type :string, :text, :integer, :float, :boolean, + :currency
8
+ :key, # true if this is the key (only :id)
9
+
10
+ # column formatting
11
+ :width, # initial width (150)
12
+ :fixed_width, # true = not resized when recalc fit to width
13
+ :formatter, # see jqGrid doc (based on value_type)
14
+ :format_options, # hash, see jqGrid doc (based on value_type)
15
+ :align, # 'left', 'right', 'center' (left for strings, right for numerics)
16
+ #:classes, # optional classes to add to column
17
+
18
+ # column actions
19
+ :resizable, # t/f (true)
20
+ :sortable, # t/f (true) or jqGrid sorttype: :integer, :float, :currency, :date, :text (true)
21
+ :searchable, # true/false (true) or text or select
22
+ #:search_options,
23
+ :editable, # true/false (false),
24
+ :edit_type, # text, textarea, select, checkbox, password, button, image and file (based on value_type)
25
+ :edit_options, # html input field options, depends on editable type (eg {"size" => 10, "maxlength" => 15}) see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:common_rules
26
+ :validations, # jqGrid editrules (TODO derive from AR model validations) see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:common_rules
27
+ # "required" "integer" "email" "url" etc
28
+ :form_options, # jqGrid formoptions for formatting input forms
29
+ # select types
30
+ #:select_url, # url to dynamically get select options
31
+
32
+ # visiblity
33
+ #:always_hidden, # (false)
34
+ :sort_type,
35
+ :summary_type,
36
+ :summary_tpl,
37
+ :hidden # initial hide state (false)
38
+
39
+ def initialize(options)
40
+ update options
41
+ end
42
+
43
+ def update(options)
44
+ options.each {|atr, val| send( "#{atr}=", val )}
45
+ end
46
+
47
+ def to_json
48
+ properties.to_json #_with_js
49
+ end
50
+
51
+ def properties
52
+ jqgrid_properties
53
+ end
54
+
55
+ def resizable
56
+ if @resizable==false
57
+ false
58
+ else
59
+ # true or nil
60
+ true
61
+ end
62
+ end
63
+
64
+ def fixed_width
65
+ if @fixed_width==false
66
+ false
67
+ elsif @fixed_width.nil?
68
+ !resizable
69
+ else
70
+ @fixed_width
71
+ end
72
+ end
73
+
74
+ # ----------------
75
+ private
76
+
77
+ def jqgrid_type
78
+ return sortable unless sortable==true
79
+ case value_type
80
+ when :string : 'text'
81
+ when :text : 'text'
82
+ when :integer : 'integer'
83
+ when :float : 'float'
84
+ when :boolean : 'boolean'
85
+ when :datetime : 'date'
86
+ end
87
+ end
88
+
89
+ # note, we dont vals[:foo] = foo because dont want to bother generating key if its same as jqGrid default
90
+ def jqgrid_properties
91
+ vals = {
92
+ :name => name,
93
+ :index => name
94
+ }
95
+ #xmlmap not required when same as :name
96
+ # vals[:xmlmap] = name if data_type == :xml
97
+ # vals[:jsonmap] = name if data_type == :json
98
+
99
+ vals[:label] = label || name.titleize
100
+ vals[:resizable] = false if resizable==false
101
+ vals[:fixed] = fixed_width unless fixed_width==false
102
+ vals[:sortable] = false if sortable==false
103
+ vals[:sort_type] = jqgrid_type if sortable
104
+ vals[:search] = false if searchable==false
105
+ vals[:editable] = true if editable
106
+ vals[:align] = align if align
107
+ #vals[:align] = 'right' if [:integer, :float, :currency].include?(value_type)
108
+ case value_type
109
+ when :datetime
110
+ vals[:formatter] = 'date'
111
+ vals[:formatoptions] = { :srcformat => 'UniversalSortableDateTime', :newformat => 'FullDateTime' }
112
+ end
113
+ vals[:hidden] = true if hidden
114
+ vals[:width] = width if width
115
+ vals[:formatter] = formatter if formatter
116
+ vals[:formatoptions] = format_options if format_options
117
+ vals[:edittype] = edit_type if editable && edit_type
118
+ vals[:formoptions] = form_options if editable && form_options
119
+ vals[:editoptions] = edit_options if editable && edit_options
120
+ vals[:editrules] = validations if editable && validations
121
+
122
+ vals[:sort_type] = sort_type if sort_type
123
+ vals[:summaryType] = summary_type if summary_type
124
+ vals[:summaryTpl] = summary_tpl if summary_tpl
125
+ # and more...
126
+
127
+ vals
128
+ end
129
+
130
+ end
131
+ end
132
+
133
+ #<ActiveRecord::ConnectionAdapters::SQLiteColumn:0x2515a98 @sql_type="varchar(255)", @name="title", @precision=nil, @primary=false, @default=nil, @limit=255, @null=true, @type=:string, @scale=nil>
134
+