Changeset 1055

Show
Ignore:
Timestamp:
2008-06-10 15:11:34 (7 months ago)
Author:
gaspard
Message:

Fixed bugs to enable [drop] in [each] context. Fixed bugs where an object could appear with a dom_id already used.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/app/views/nodes/edit.rjs

    r857 r1055  
    44  page << "$('node_#{params[:attribute]}').select();" 
    55else 
    6   page.replace "#{dom_id_from_template_url}.#{@node[:zip]}", :file => fullpath_from_template_url + "_form.erb" 
     6  page.replace "#{params[:dom_id]}", :file => fullpath_from_template_url + "_form.erb" 
    77end 
  • trunk/app/views/nodes/update.rjs

    r918 r1055  
    11if @errors || !@node.errors.empty? 
    22  if @update == 'zafu' 
    3     page.replace "#{dom_id_from_template_url}.#{@node[:zip]}", :file => fullpath_from_template_url + "_form.erb" 
     3    page.replace "#{params[:dom_id]}", :file => fullpath_from_template_url + "_form.erb" 
    44  else 
    55    # TODO: is this used ? how ? when ? 
  • trunk/db/init/base/skins/default/Node.zafu

    r1032 r1055  
    1919    <div id='login' do='login_link'/> 
    2020    <div id='visitor' do='visitor_link'/> 
    21     <div id='search' do='search_box'/> 
     21    <div id='search' do='search_box' type='search'/> 
    2222    <ol id='menu' do='root' do='pages'> 
    2323      <li do='each' on_if_node='ancestor' do='link'/> 
     
    8080          </ol> 
    8181        </r:references> 
    82          
     82 
    8383      </div> 
    8484      <div id='main'> 
  • trunk/db/init/base/skins/default/Project.zafu

    r1010 r1055  
    11<r:include template='Node'> 
    2   <r:with part='content'> 
     2  <r:with part='context'/> 
     3  <r:with part='content' class='project'> 
    34    <r:include template='Node' part='related'/> 
    4     <div id='main' do='text'/> 
     5    <r:text/> 
    56    <r:include template='notes'/> 
    67  </r:with> 
  • trunk/db/init/base/skins/default/notes.zafu

    r1032 r1055  
    66        <p class='node_v_title'><input type='text' name='v_title' size='25'/></p> 
    77        <p class='node_klass'>  <r:select name='klass' root_class='Note' selected='Post'/></p> 
    8         <p class='node_log_at'> <input type='date_box' name='log_at'/> <r:checkbox role='blog' values='11'/></p> 
     8        <p class='node_log_at'> <input type='date_box' name='log_at'/> </p> 
    99        <p class='validate'>    <input type="submit" value='validate' do='void' tset_value='validate'/></p> 
    1010      </form> 
  • trunk/db/init/base/skins/default/style.css

    r1049 r1055  
    33a.wiki { color:inherit; border-bottom:1px dotted blue;} 
    44.zazen a:hover, #footer a:hover { border-bottom:1px solid blue;} 
     5input { padding:3px 4px;} 
     6 
    57#header, #container, #footer, #top { width:800px; border:1px solid #555; border-width:0 1px 1px; margin:0 auto; background:white; padding:100px 21px;} 
    68#header { background:orange; padding:7px 21px; position:relative; color:white;} 
     
    1820#title { margin:0 42px 42px 200px; color:black;} 
    1921#title h1 { font-size:35px; margin:0;} 
    20 .summary p { margin:0; text-style:italic; font-family:Times; font-size:120%;} 
     22.summary p { margin:0; text-style:italic; font-family:Georgia,Times,serif; color:black;} 
    2123#context { width:180px; float:left; border-right:1px solid grey;} 
    2224ol { padding-left:14px;} 
    2325 
    24 #content { margin-left: 200px;} 
     26#content { margin-left: 200px; } 
     27#content.project { margin:18px;} 
    2528#related { width:150px; float:right; margin:-7px 0 14px 14px; border:1px dotted #bbb; padding:7px; font-size:12px; line-height:21px; background:#f4f4f4;} 
    2629 
     
    5659 
    5760/* notes */ 
    58 .note { border-bottom:2px solid #bbb; margin:35px 0; padding:0 21px;} 
    59 .note .log_at { float:right; font-style:italic; color:grey; padding-top:14px;} 
    60 .note h2.title, .note .header p { margin:0;} 
     61.note { border-bottom:1px solid #999; margin:0 0 42px; padding:0;} 
     62.note .header p { margin:0;} 
     63.note p.log_at { float:right; font-style:italic; color:grey; font-size:14px; line-height:42px; margin-right:10px;} 
     64.note h2.title { color:#200; font-size:14px; line-height:42px; font-weight:bold; font-family:Georgia,Times,serif; font-size:24px; line-height:42px;} 
     65.note .title a { color:inherit;} 
    6166 
    6267.inline_form { margin:2px; padding:3px; border:1px dotted grey; font-size:80%; background:#eed;} 
  • trunk/lib/parser/lib/parser.rb

    r1034 r1055  
    127127    @blocks   = obj.blocks.empty? ? @blocks : obj.blocks 
    128128    @params   = obj.params.empty? ? @params : obj.params 
    129     @params[:id] = @name 
    130129  end 
    131130   
  • trunk/lib/parser/lib/rules/zafu.rb

    r1032 r1055  
    88    def replace_with(new_obj) 
    99      super 
     10      html_tag_params    = new_obj.html_tag_params 
     11      [:class, :id].each do |sym| 
     12        html_tag_params[sym] = new_obj.params[sym] if new_obj.params.include?(sym) 
     13      end 
    1014      @html_tag          = new_obj.html_tag || @html_tag 
    11       @html_tag_params   = !new_obj.html_tag_params.empty? ? new_obj.html_tag_params : @html_tag_params 
     15      @html_tag_params.merge!(html_tag_params) 
    1216    end 
    1317     
  • trunk/lib/parser/lib/rules/zena.rb

    r1045 r1055  
    175175       
    176176      res ||= super(method) 
    177        
    178177      "#{pre}#{res}#{post}" 
    179178    end 
     
    650649        else 
    651650          # edit button 
     651          dom_id = parent.method == 'each' ? @context[:dom_id] : unique_name 
     652          dom_id = "#{dom_id}.\#{#{node_id}}" 
     653 
     654          action = "?template_url=#{CGI.escape(template_url)}" 
     655          action << "&dom_id=#{dom_id}" 
    652656          # TODO: show 'reply' instead of 'edit' in comments if visitor != author 
    653           "<%= #{node}.can_write? ? link_to_remote(#{text || _('edit').inspect}, {:url => edit_#{base_class.to_s.underscore}_path(#{node_id}) + '?template_url=#{CGI.escape(template_url)}', :method => :get}#{params_to_erb(@params)}) : '' %>" 
     657          "<%= #{node}.can_write? ? link_to_remote(#{text || _('edit').inspect}, {:url => edit_#{base_class.to_s.underscore}_path(#{node_id}) + \"#{action}\", :method => :get}#{params_to_erb(@params)}) : '' %>" 
    654658        end 
    655659      else 
     
    9971001      template_url = get_template_url 
    9981002      @html_tag_params ||= {} 
    999       @html_tag_params[:id] = @html_tag_params[:id] ? CGI.escape(@html_tag_params[:id]) : template_url 
     1003      dom_id = parent.method == 'each' ? @context[:erb_dom_id] : unique_name 
     1004      @html_tag_params[:id] = "#{dom_id}.#{erb_node_id}" 
    10001005      @html_tag_params[:class] ||= 'drop' 
    10011006       
     
    10401045  
    10411046    def r_unlink 
    1042       text = expand_with 
     1047      text = get_text_for_erb 
    10431048      if text.blank? 
    10441049        text = _('btn_tiny_del') 
    10451050      end 
    1046       dom_id = "#{CGI.escape(@context[:dom_id])}.\#{#{node_id}}" 
     1051      #dom_id = "#{@context[:dom_id]}.\#{#{node_id}}" 
     1052      dom_id = "#{@context[:erb_dom_id]}.#{erb_node_id}" 
    10471053      if node_kind_of?(Node) 
    1048         out "<% if #{node}[:link_id] -%><%= link_to_remote(#{text.inspect}, {:url =>  \"/nodes/\#{#{node}[:zip]}/links/\#{#{node}[:link_id]}?remove=#{dom_id}\", :method => :delete}, :class=>#{(@params[:class] || 'unlink').inspect}) %><% end -%>" 
     1054        out "<% if #{node}[:link_id] -%>" 
     1055        out "<a class='#{@params[:class] || 'unlink'}' href='/nodes/#{erb_node_id}/links/<%= #{node}[:link_id] %>?remove=#{dom_id}' onclick=\"new Ajax.Request('/nodes/#{erb_node_id}/links/<%= #{node}[:link_id] %>?remove=#{dom_id}', {asynchronous:true, evalScripts:true, method:'delete'}); return false;\">" 
     1056        if !@blocks.empty? 
     1057          out expand_with 
     1058        else 
     1059          out _('btn_tiny_del') 
     1060        end 
     1061        out "</a><% end -%>" 
    10491062      elsif node_kind_of?(DataEntry)   
    10501063        out "<%= link_to_remote(#{text.inspect}, {:url => \"/data_entries/\#{#{node}[:id]}?remove=#{dom_id}\", :method => :delete}, :class=>#{(@params[:class] || 'unlink').inspect}) %>" 
     
    11511164        #dom_id = @context[:template_url] || self.dom_id() 
    11521165         
     1166        erb_dom_id = "#{self.dom_id}.#{erb_node_id}" 
     1167        dom_id     = "#{self.dom_id}.\#{#{node_id}}" 
     1168         
    11531169        if @params[:draggable] == 'true' 
    11541170          out "<% #{var}_dom_ids << \"#{dom_id}.\#{#{node_id(var)}}\" -%>" 
     
    11611177        if @context[:template_url] || @params[:draggable] == 'true' || descendant('unlink') 
    11621178          # ajax, set id 
    1163           id_hash = {:id=>"#{dom_id}.#{erb_node_id(var)}"} 
     1179          id_hash = {:id=> "#{erb_dom_id}.#{erb_node_id(var)}"} 
    11641180          if @html_tag 
    11651181            @html_tag_params.merge!(id_hash) 
    1166             res = expand_with(:node=>var, :dom_id=>dom_id) # dom_id is needed by 'unlink
     1182            res = expand_with(:node=>var, :dom_id=>dom_id, :erb_dom_id=>erb_dom_id) # dom_id is needed by 'unlink' and 'drop
    11671183          else 
    1168             res = add_params(expand_with(:node=>var, :dom_id=>dom_id), id_hash) 
     1184            res = add_params(expand_with(:node=>var, :dom_id=>dom_id, :erb_dom_id=>erb_dom_id), id_hash) 
    11691185          end 
    11701186        else 
     
    19761992        
    19771993    def add_params(text, opts={}) 
    1978       text.sub(/\A([^<]*)<(\w+)( [^>]+|)>/) do 
     1994      text.sub(/\A([^<]*)<(\w+)( .*?)[^%]>/) do 
    19791995        # we must set the first tag id 
    19801996        before = $1 
  • trunk/lib/parser/test/parser/zafu.yml

    r1006 r1055  
    128128 
    129129named_with_do: 
    130   src: "named_with_do: <p id='branding' do='void'>...</p>" 
     130  src: "named_with_do: <p id='branding'>...</p>" 
    131131  res: "named_with_do: <p id='branding'>...</p>" 
    132132 
    133133replace_with_do: 
    134   src: "replace_with_do: <r:include template='/named/with/do'><r:with part='branding'>lalala</r:with>" 
    135   res: "replace_with_do: named_with_do: <p id='branding'>lalala</p>" 
     134  src: "replace_with_do: <r:include template='/named/with/do'><r:with part='branding' class='goal'>lalala</r:with>" 
     135  res: "replace_with_do: named_with_do: <p class='goal' id='branding'>lalala</p>" 
    136136 
    137137include_part: