Skip to content
Browse files

create universal make_arrows macro

  • Loading branch information...
1 parent a371b04 commit 7c670eb8bbd5bce5e7ec086405105a9c2d04c93c @adrianoldham adrianoldham committed with Nov 11, 2013
Showing with 16 additions and 8 deletions.
  1. +16 −8 site/templates/preload.tmpl
View
24 site/templates/preload.tmpl
@@ -367,26 +367,34 @@ parameters:
which in most cases means you can just supply parent
-:>
<:.if request.user_can("bse_edit_reorder_children", parent) -:>
+ <:.set down_url = loop.next ? cfg.admin_url("move", { "stepparent":parent.id, "d":"swap", "id":loop.current.id, "other":loop.next.id, "r":top.admin }) : 0 -:>
+ <:.set up_url = loop.prev ? cfg.admin_url("move", { "stepparent":parent.id, "d":"swap", "id":loop.current.id, "other":loop.prev.id, "r":top.admin }) : 0 -:>
+ <:.set class = cfg.entry("arrows", "class", "bse_arrows") -:>
+ <span class="<:= m.class :>">
+ <:-.call "make_arrows", "down_url":down_url, "up_url":up_url -:>
+ </span>
+<:.end if -:>
+<:.end define -:>
+
+<:.define make_arrows -:>
+<:# expects down_url, up_url
+-:>
<:.set width = cfg.entry("arrows", "image_width", 17) -:>
<:.set height = cfg.entry("arrows", "image_height", 13) -:>
<:.set extras = 'width="' _ width _ '" height="' _ height _ '"' -:>
- <:.set class = cfg.entry("arrows", "class", "bse_arrows") -:>
<:.set blank_img = '<img src="' _ (dist_image_uri _ "/trans_pixel.gif").escape("html") _ '" alt="" ' _ extras _ ' />' -:>
<:.set down_img = '<img src="' _ cfg.entry("arrows", "downimg", dist_image_uri _ "/admin/move_down.gif").escape("html") _ '" alt="Down" ' _ extras _ ' />' -:>
<:.set up_img = '<img src="' _ cfg.entry("arrows", "upimg", dist_image_uri _ "/admin/move_up.gif").escape("html") _ '" alt="Up" ' _ extras _ ' />' -:>
- <span class="<:= class :>">
- <:-.if loop.next -:>
- <a href="<:= cfg.admin_url("move", { "stepparent":parent.id, "d":"swap", "id":loop.current.id, "other":loop.next.id, "r":top.admin }) :>"><:= down_img |raw:></a>
+ <:-.if down_url -:>
+ <a href="<:= down_url :>"><:= down_img |raw:></a>
<:-.else -:>
<:= blank_img |raw:>
<:-.end if -:>
- <:.if loop.prev -:>
- <a href="<:= cfg.admin_url("move", { "stepparent":parent.id, "d":"swap", "id":loop.current.id, "other":loop.prev.id, "r":top.admin }) :>"><:= up_img |raw:></a>
+ <:-.if up_url -:>
+ <a href="<:= up_url :>"><:= up_img |raw:></a>
<:-.else -:>
<:= blank_img |raw:>
<:-.end if -:>
- </span>
-<:.end if -:>
<:.end define -:>

0 comments on commit 7c670eb

Please sign in to comment.
Something went wrong with that request. Please try again.