Changeset 1126
- Timestamp:
- 2008-07-26 13:43:45 (6 months ago)
- Files:
-
- trunk/lib/parser/lib/rules/zena.rb (modified) (14 diffs)
- trunk/public/images/shading.png (modified) (previous)
- trunk/public/stylesheets/zena.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/parser/lib/rules/zena.rb
r1125 r1126 530 530 end 531 531 out "</div></form>" 532 if @params[:live] 532 if @params[:live] || @params[:updatea] 533 533 out "<%= observe_form( \"#{dom_id}_f\" , :method => :get, :frequency => 1, :submit =>\"#{dom_id}_f\", :url => zafu_node_path(#{node_id})) %>" 534 534 end … … 693 693 else 694 694 @html_tag_params[:class] = ["'s<%= #{node}.version.status %>'"] 695 @html_tag ||= 'span' 695 696 res 696 697 end … … 1216 1217 1217 1218 def r_drop 1218 @html_tag_params[:class] ||= 'drop' 1219 if parent.method == 'each' && @method == parent.single_child_method 1220 parent.add_html_class('drop') 1221 else 1222 @html_tag_params[:class] ||= 'drop' 1223 end 1219 1224 r_block 1220 1225 end … … 1252 1257 new_dom_scope 1253 1258 @html_tag ||= 'div' 1254 @html_tag_params ||= {}1255 dom_id = unique_name1256 @html_tag_params[:id] = erb_dom_id1257 1259 case @params[:revert] 1258 1260 when 'move' … … 1263 1265 revert_effect = 'Element.move' 1264 1266 end 1265 res = expand_with 1266 if @params[:drag_handle] 1267 drag_handle = @params[:drag_handle] == 'true' ? 'drag_hand' : @params[:drag_handle] 1268 if res =~ /class\s*=\s*['"]#{drag_handle}/ 1269 # nothing to do 1270 insert = '' 1271 else 1272 insert = "<span class='#{drag_handle}'> </span>" 1273 end 1274 else 1275 insert = '' 1276 end 1277 out render_html_tag(insert + res) 1278 1279 out "<script type='text/javascript'> 1280 //<![CDATA[" 1267 1268 res, drag_handle = set_drag_handle_and_id(expand_with, @params, :id => erb_dom_id) 1269 1270 out render_html_tag(res) 1271 1281 1272 if drag_handle 1282 1273 out "<script type='text/javascript'>\n//<![CDATA[\n 1283 new Draggable('#{@html_tag_params[:id]}', {ghosting:true, revert:true, revertEffect:#{revertEffect}, handle:$(dom_id).select('.#{drag_handle}')[0]}); 1284 });\n//]]>\n</script>" 1285 else 1286 out "<script type='text/javascript'>\n//<![CDATA[\nZena.draggable('#{@html_tag_params[:id]}',0,true,true,#{revert_effect})\n//]]>\n</script>" 1274 new Draggable('#{erb_dom_id}', {ghosting:true, revert:true, revertEffect:#{revert_effect}, handle:$('#{erb_dom_id}').select('.#{drag_handle}')[0]});\n//]]>\n</script>" 1275 else 1276 out "<script type='text/javascript'>\n//<![CDATA[\nZena.draggable('#{erb_dom_id}',0,true,true,#{revert_effect})\n//]]>\n</script>" 1287 1277 end 1288 1278 end … … 1419 1409 1420 1410 def r_each 1421 if descendant('edit') || descendant('unlink') || ['block', 'drop'].include?(single_child_method) || @params[:draggable] == 'true' 1411 is_draggable = @params[:draggable] == 'true' || @params[:drag_handle] 1412 1413 if descendant('edit') || descendant('unlink') || ['block', 'drop'].include?(single_child_method) || is_draggable 1422 1414 id_hash = {:id => erb_dom_id} 1423 1415 else 1424 1416 id_hash = nil 1425 1417 end 1418 1426 1419 1427 1420 if @context[:make_form] … … 1430 1423 elsif @context[:list] 1431 1424 # normal rendering: not the start of a saved template 1432 if @params[:draggable] == 'true'|| descendant('unlink')1425 if is_draggable || descendant('unlink') 1433 1426 @html_tag ||= 'div' 1434 1427 out "<% #{var}_dom_ids = [] -%>" … … 1457 1450 end 1458 1451 1459 if @params[:draggable] == 'true'1452 if is_draggable 1460 1453 out "<% #{var}_dom_ids << \"#{dom_id}\" -%>" 1461 1454 end … … 1465 1458 @anchor_param = nil 1466 1459 1467 res = expand_with(:node => var, :scope_node => var) 1468 1469 if @params[:drag_handle] && @params[:draggable] == 'true' 1470 drag_handle = @params[:drag_handle] == 'true' ? 'drag_handle' : @params[:drag_handle] 1471 if res =~ /class\s*=\s*['"]#{drag_handle}/ 1472 # nothing to do 1473 insert = '' 1474 else 1475 insert = "<span class='#{drag_handle}'> </span>" 1476 end 1477 else 1478 insert = '' 1479 end 1480 1481 if id_hash 1482 if @html_tag 1483 @html_tag_params.merge!(id_hash) 1484 res = insert + res 1485 else 1486 res = add_params(res, id_hash, insert) 1487 end 1488 end 1489 1460 res, drag_handle = set_drag_handle_and_id(expand_with(:node => var, :scope_node => var), @params, id_hash) 1490 1461 1491 1462 out render_html_tag(res, html_append) … … 1493 1464 out "<% end -%>" 1494 1465 1495 if @params[:draggable] == 'true'1466 if is_draggable 1496 1467 if drag_handle 1497 1468 out "<script type='text/javascript'>\n//<![CDATA[\n<%= #{var}_dom_ids.inspect %>.each(function(dom_id, index) { … … 1505 1476 elsif @context[:saved_template] 1506 1477 # render to start a saved template 1507 res = expand_with(:scope_node => node) 1508 1509 if id_hash 1510 if @html_tag 1511 @html_tag_params.merge!(id_hash) 1512 res = render_html_tag(res, html_append) 1478 res, drag_handle = set_drag_handle_and_id(expand_with(:scope_node => node), @params, id_hash) 1479 1480 out render_html_tag(res) 1481 1482 if is_draggable 1483 if drag_handle 1484 out "<script type='text/javascript'>\n//<![CDATA[\nnew Draggable('#{erb_dom_id}', {ghosting:true, revert:true, handle:$('#{erb_dom_id}').select('.#{drag_handle}')[0]});\n//]]>\n</script>" 1513 1485 else 1514 res = add_params(res, id_hash) 1515 end 1516 end 1517 1518 out res 1519 1520 if @params[:draggable] == 'true' 1521 out "<script type='text/javascript'>\n//<![CDATA[\nZena.draggable('#{erb_dom_id}')\n//]]>\n</script>" 1486 out "<script type='text/javascript'>\n//<![CDATA[\nZena.draggable('#{erb_dom_id}')\n//]]>\n</script>" 1487 end 1522 1488 end 1523 1489 else … … 1527 1493 end 1528 1494 end 1529 1495 1530 1496 def r_case 1531 1497 out "<% if false -%>" … … 2611 2577 when 'main' 2612 2578 "#{node}[:id] == #{node_name}[:id]" 2579 when 'start' 2580 "#{node}[:zip] == (params[:s] || #{node_name}[:zip]).to_i" 2613 2581 when 'parent' 2614 2582 "#{node}[:id] == #{node_name}[:parent_id]" … … 3158 3126 end 3159 3127 3128 # Used by [each] and [draggable] to insert 'id' and drag handle span 3129 def set_drag_handle_and_id(text, params, id_hash) 3130 res, drag_handle = text, nil 3131 if params[:drag_handle] 3132 drag_handle = params[:drag_handle] == 'true' ? 'drag_handle' : params[:drag_handle] 3133 if text =~ /class\s*=\s*['"]#{drag_handle}/ 3134 # nothing to do 3135 insert = '' 3136 else 3137 insert = "<span class='#{drag_handle}'> </span>" 3138 end 3139 else 3140 insert = '' 3141 end 3142 3143 if id_hash 3144 if @html_tag 3145 @html_tag_params.merge!(id_hash) 3146 res = insert + text 3147 else 3148 res = add_params(text, id_hash, insert) 3149 end 3150 end 3151 [res, drag_handle] 3152 end 3153 3160 3154 def expand_with(acontext={}) 3161 3155 # set variables trunk/public/stylesheets/zena.css
r1124 r1126 36 36 37 37 /* ========================= Ajax css ========================= */ 38 .drop_hover { background:#ace; border:2px dashed #99f;}38 .drop_hover { background:#ace; border:2px dashed #99f;} 39 39 .drop { min-height:1em;} 40 .drag_handle { padding-left:1em; margin:2px; background: #bbf;}40 .drag_handle { padding-left:1em; margin:2px; background: url('/images/shading.png');} 41 41 42 42 /* ========================= Zazen css ======================== */
