Changeset 1132

Show
Ignore:
Timestamp:
2008-08-14 21:18:56 (5 months ago)
Author:
gaspard
Message:

Added 'alt_reverse' option to [each] to display stripes starting at the bottom of the list.
Added special 'stored' value 'start.id' to get, the zip of the start page (client browser page) deep in nested ajax calls.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/parser/lib/rules/zena.rb

    r1131 r1132  
    14291429         
    14301430        @params[:alt_class] ||= @html_tag_params.delete(:alt_class) 
    1431         raise # TODO: add alt_reverse='true' to start counting from bottom (if order last on top...) 
     1431        # FIXME: add alt_reverse='true' to start counting from bottom (if order last on top...) 
    14321432        if @params[:alt_class] || @params[:join] 
    14331433          join = @params[:join] || '' 
    14341434          join = join.gsub(/&lt;([^%])/, '<\1').gsub(/([^%])&gt;/, '\1>') 
     1435          out "<% #{var}_max_index = #{list}.size - 1 -%>" if @params[:alt_reverse] 
    14351436          out "<% #{list}.each_with_index do |#{var},#{var}_index| -%>" 
    14361437          out "<%= #{var}_index > 0 ? #{join.inspect} : '' %>" 
    14371438           
    14381439          if alt_class = @params[:alt_class] 
     1440            alt_test = @params[:alt_reverse] == 'true' ? "(#{var}_max_index - #{var}_index) % 2 != 0" : "#{var}_index % 2 != 0" 
    14391441            if html_class = @html_tag_params.delete(:class) 
    1440               html_append = " class='#{html_class}<%= #{var}_index % 2 != 0 ? #{(' ' + alt_class).inspect} : '' %>'" 
     1442              html_append = " class='#{html_class}<%= #{alt_test} ? #{(' ' + alt_class).inspect} : '' %>'" 
    14411443            else 
    1442               html_append = "<%= #{var}_index % 2 != 0 ? ' class=#{alt_class.inspect}' : '' %>" 
     1444              html_append = "<%= #{alt_test} ? ' class=#{alt_class.inspect}' : '' %>" 
    14431445            end 
    14441446          else 
     
    25782580                "#{node}[:id] == #{node_name}[:id]" 
    25792581              when 'start' 
    2580                 "#{node}[:zip] == (params[:s] || #{node_name}[:zip]).to_i" 
     2582                "#{node}[:zip] == (params[:s] || @node[:zip]).to_i" 
    25812583              when 'parent' 
    25822584                "#{node}[:id] == #{node_name}[:parent_id]" 
     
    26992701     
    27002702    def node_attribute(str, opts={}) 
     2703      return "(params[:s] || @node[:zip]).to_i" if str == 'start.id' 
    27012704      attribute, att_node, klass = get_attribute_and_node(str) 
    27022705      return 'nil' unless attribute 
     
    29262929      else 
    29272930        attribute = res[:name] 
    2928         if @context[:in_filter] 
     2931        if @context[:in_filter] || attribute == 's' 
    29292932          res[:name] = attribute 
    29302933        else 
  • trunk/test/helpers/zena_parser/ajax.yml

    r1131 r1132  
    180180start_id: 
    181181  src: "<r:form><input type='hidden' name='s' set_value='[start.id]'/></r:form>" 
    182   res: ".
     182  res: "/<input name='s' type='hidden' value='22'/>/
  • trunk/test/helpers/zena_parser/basic.yml

    r1128 r1132  
    448448  src: "<ol do='pages'><li do='each' alt_class='blue' do='[name]'/></ol>" 
    449449  res: "<ol><li>status</li><li class=\"blue\">track</li></ol>" 
     450 
     451each_alternate_class_reverse: 
     452  context: 
     453    node: 'cleanWater' 
     454  src: "<ol do='pages'><li do='each' alt_class='blue' alt_reverse='true' do='[name]'/></ol>" 
     455  res: "<ol><li class=\"blue\">status</li><li>track</li></ol>" 
    450456 
    451457each_alternate_class_two: