fisheye_menu.anubis 2.3 KB
/*
 * Created by PyramIDE.
 * User: フランスのトトロ 
 * Date: 09/05/2015
 * Time: 22:33
 * © Calexium 
 */

transmit tools/basis.anubis
transmit calexium_lib/web/CXM_making_a_web_site.anubis
read calexium_lib/web/jQuery/CXM_jquery_animate.anubis
read calexium_lib/web/CXM_jquery.anubis

public type FisheyeEntry:
  fisheye_entry(
    String  id,             //html id 
    String  icon_path,      //path of the icon to shown with this entry
    String  action,         //action to do when click on that icon
    String  help_text       //Help text to show
    ).
    
define List(HTML_Off_Form)
  make_fisheye_menu 
  (
    (String) -> String  _T,               //translator function
    List(FisheyeEntry)  entries,
    List(HTML_Off_Form) so_far,
    String              selected_space  //id of the selected space
  )=
  if entries is 
  {
    []      then reverse(so_far),  //reverse to be in the right direction
    [h . t] then
      with entry = (HTML_Off_Form)image(
                          [
                            id(h.id),
                            class("menu_item"+if h.id = selected_space then " menu_selected" else ""),
                            event(onclick,"location.href='?a="+h.action+"';"),
                            attr("widgetid",h.id),
                            attr("title",_T(h.help_text))
                          ],
                          h.icon_path,
                          _T(h.help_text)),

      make_fisheye_menu(_T, t, [ entry . so_far], selected_space)
  }.
  
public define HTML_Partial_Content
  make_fisheye_menu 
  (
    (String) -> String  _T,               //translator function
    List(FisheyeEntry)  entries,          //List of all eyes to show
    String              selected_space    //html id of the selected eye (means that it will be surrounded with square to indicate the selection)
  )=
  if entries is
  {
    []      then partial_content([], literal("")),
    [_ . _] then partial_content(jquery_animate(childs(htmlId("top_menu")), size_on_hover(64, 64, 1000, 1000)), 
    
         div([id("top_menu"), style("min-height:70px!important;vertical-align:top;display:table-row")],
                sequence([

                    //Liste des espaces
                    sequence(make_fisheye_menu(_T, entries, [], selected_space))
                ])
            ))
    
  }.