create universal make_arrows macro
authorAdrian Oldham <adriann@visualthought.com.au>
Mon, 11 Nov 2013 12:02:26 +0000 (23:02 +1100)
committerTony Cook <tony@develop-help.com>
Mon, 24 Feb 2014 22:23:58 +0000 (09:23 +1100)
site/templates/preload.tmpl

index e24dc9a98fbf548dad850c85f5db3bec4d749819..fd53362658087f5947f83ffcb226d23e734f45f7 100644 (file)
@@ -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 -:>