Module: PropertyGrid

Defined in:
lib/property_grid.rb,
lib/property_grid/version.rb

Defined Under Namespace

Classes: APropertyGrid, ControlType, GroupProperty, PropertyGridGroup, PropertyGridTypes

Constant Summary collapse

VERSION =
"0.0.1"

Instance Method Summary collapse

Instance Method Details

#generate_javascript_for_property_groups(grid) ⇒ Object

********************************** Helper functions



136
137
138
139
140
141
142
143
144
# File 'lib/property_grid.rb', line 136

def generate_javascript_for_property_groups(grid)
  javascript = ''

  grid.groups.each_with_index do |grp, index|
    javascript << get_javascript_for_group(index)
  end

  javascript
end

#get_javascript_for_group(index) ⇒ Object



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/property_grid.rb', line 146

def get_javascript_for_group(index)
  js = %Q|
    $(".expandableGroup[idx]").click(function()
    {
      var hidden = $(".property_group[idx]").is(":hidden");       // get the value BEFORE making the slideToggle call.
      $(".property_group[idx]").slideToggle('slow');

                                                                  // At this point,  $(".property_group0").is(":hidden");
                                                                  // ALWAYS RETURNS FALSE

      if (!hidden)                                                // Remember, this is state that the div WAS in.
      {
        $(".expandableGroup[idx]").removeClass('expanded');
        $(".expandableGroup[idx]").addClass('collapsed');
      }
      else
      {
        $(".expandableGroup[idx]").removeClass('collapsed');
        $(".expandableGroup[idx]").addClass('expanded');
      }
    });
  |.gsub('[idx]', index.to_s)

  js
end

#group(name) ⇒ Object



119
120
121
122
123
124
125
# File 'lib/property_grid.rb', line 119

def group(name)
  group = PropertyGridGroup.new
  group.name = name
  @__property_grid.groups << group

  group
end

#group_property(name, var, type = :string, collection = nil) ⇒ Object



127
128
129
130
131
132
# File 'lib/property_grid.rb', line 127

def group_property(name, var, type = :string, collection = nil)
  group_property = GroupProperty.new(var, name, type, collection)
  @__property_grid.groups.last.properties << group_property

  group_property
end

#new_property_grid(name = nil) ⇒ Object

********************************** DSL functions



113
114
115
116
117
# File 'lib/property_grid.rb', line 113

def new_property_grid(name = nil)
  @__property_grid = APropertyGrid.new

  @__property_grid
end