[pmwiki-devel] What FixURL changes mean for AddToggle

Randy Brown randy at brownragfilms.com
Thu Jul 23 10:22:39 CDT 2015


I see that FixURL is changing. I wrote something that was modeled after the old version of FixURL, to allow easy insertion of a toggle in conjunction with the toggle recipe. I was thinking of posting it as an AddToggle recipe. Will my code stop working as a result of the changes that have been made or are being contemplated? If this won’t be affected, should I post the code below as is? All suggestions for revision or improvement are welcome.

Best,

Randy

$GUIButtons['addtoggle'] = array(9991,'','','$[Toggle link]',
 "<img src='\$GUIButtonDirUrlFmt/addtoggle.png' title='$[Add a toggle link: Selected text will become a link that hides a section until clicked.]' onclick='AddToggle()'/>");

$HTMLFooterFmt['addtoggle'] = <<<EOF
<script type="text/javascript">
function AddToggle(){
 var r = 5000 + Math.round(Math.random()*1000);
 insMarkup(
    "{(toggle "+r+" \\"",
    "\\")}\\nHidden\\n(:div"+r+"end:)\\n",
    "$[Toggle link]");
}
</script>
EOF;

This creates a markup expression that in turn calls:

# a custom markup expression to create a toggle that hides a div:  
# Usage: {(toggle N "This is my toggle link")} 
#  followed by (:divNend:), where N is a unique div number on the page
$MarkupExpr["toggle"] = 'toggle(@$args)'; 

function toggle($args) {
 
  $num = $args[0];
  $text = $args[1];

  $markupToReturn = "(:toggle id=toggle".$num." hide nojs=2 show=\"{\$Show} ".$text."\" hide=\"{\$Hide} ".$text."\":)
(:div".$num." id=toggle".$num.":)
";

 return $markupToReturn;
}

$FmtPV['$Show'] = "'▹'"; # ▿
$FmtPV['$Hide'] = "'▿'"; # ▹


More information about the pmwiki-devel mailing list