/* * Created by PyramIDE. * User: Jeremy * Date: 18/09/2012 * Time: 17:28 * * */ read xlib/web/making_a_web_site.anubis read xlib/web/jquery.anubis read xlib/web/jQuery/jq_eudock_types.anubis read tools/basis.anubis read system/string.anubis read system/convert.anubis /********************************************************************************************************/ /********************************************************************************************************/ /********************************************************************************************************/ /********************************************************************************************************/ /**************************************** ATTENTION !!! *******************************************/ /************* Le mode 'object_alignment' n'est pas fonctionnel : NE PAS L'UTILISER ! ****************/ /************************ Un recodage en jQuery de la lib JS est à prévoir **************************/ /********************************************************************************************************/ /********************************************************************************************************/ /********************************************************************************************************/ /********************************************************************************************************/ /* jQuery euDock initialization */ public define List(HTML_Head_Tag) jquery_eudock_init ( String web_dir, ) = [ js(js_file("/js/jquery/euDock.2.0.js")), //js(js_file("/js/jquery/euDock.Blank.js")), // not needed for now //js(js_file("/js/jquery/euDock.DivMousePos.js")), // not needed for now //js(js_file("/js/jquery/euDock.Ghost.js")), // not needed for now js(js_file("/js/jquery/euDock.Image.js")), //js(js_file("/js/jquery/euDock.Label.js")) // not needed for now ] . /* Recursive format of the bar */ define String _jquery_eudock_format_bar ( List(JQ_eudock_imagebar) bar_images, String formatted ) = if bar_images is { [] then formatted, [ h . t ] then if h is { jq_eudock_bar_top(image) then if t is { [] then _jquery_eudock_format_bar(t, formatted+"top :{euImage:{image:'"+image.image_url+"'}}"), [ h . t] then _jquery_eudock_format_bar(t, formatted+"top :{euImage:{image:'"+image.image_url+"'}},") }, jq_eudock_bar_vertical(image) then if t is { [] then _jquery_eudock_format_bar(t, formatted+"vertical :{euImage:{image:'"+image.image_url+"'}}"), [ h . t] then _jquery_eudock_format_bar(t, formatted+"vertical :{euImage:{image:'"+image.image_url+"'}},") }, jq_eudock_bar_bottom(image) then if t is { [] then _jquery_eudock_format_bar(t, formatted+"bottom :{euImage:{image:'"+image.image_url+"'}}"), [ h . t] then _jquery_eudock_format_bar(t, formatted+"bottom :{euImage:{image:'"+image.image_url+"'}},") }, jq_eudock_bar_left(image) then if t is { [] then _jquery_eudock_format_bar(t, formatted+"left :{euImage:{image:'"+image.image_url+"'}}"), [ h . t] then _jquery_eudock_format_bar(t, formatted+"left :{euImage:{image:'"+image.image_url+"'}},") }, jq_eudock_bar_horizontal(image) then if t is { [] then _jquery_eudock_format_bar(t, formatted+"horizontal :{euImage:{image:'"+image.image_url+"'}}"), [ h . t] then _jquery_eudock_format_bar(t, formatted+"horizontal :{euImage:{image:'"+image.image_url+"'}},") }, jq_eudock_bar_right(image) then if t is { [] then _jquery_eudock_format_bar(t, formatted+"right :{euImage:{image:'"+image.image_url+"'}}"), [ h . t] then _jquery_eudock_format_bar(t, formatted+"right :{euImage:{image:'"+image.image_url+"'}},") } } } . /* Format the bar */ define String jquery_eudock_format_bar ( String dockname, JQ_eudock_bar bar ) = dockname+".setBar({"+ _jquery_eudock_format_bar(bar.bar_images, "")+ "});" . /* Format 1 icon */ define String _jquery_eudock_format_icon ( String dockname, JQ_euDock_Icon icon ) = if icon is jq_eudock_icon(icon_image, link) then " "+dockname+".addIcon(new Array({euImage:{image:'"+icon_image.image_url+"'}}), {link:'"+link+"'});\n" // space added at the beginning to avoid any js syntax error . /* Format icons */ define String _jquery_eudock_format_icons ( String dockname, List(JQ_euDock_Icon) icons, String formatted ) = if icons is { [] then formatted, [ h . t ] then _jquery_eudock_format_icons(dockname, t, formatted+ _jquery_eudock_format_icon(dockname, h)) } . /* Format icons */ define String jquery_eudock_format_icons ( String dockname, List(JQ_euDock_Icon) icons ) = _jquery_eudock_format_icons(dockname, icons, "") . /* Format alignment */ define String jquery_eudock_format_alignment ( String dockname, JQ_euDock_alignment alignment ) = if alignment is { jq_eudock_screen_alignment(a, o) then dockname+".setScreenAlign("+jq_eudock_align_to_string(a)+", "+o+");", jq_eudock_object_alignment(o_id, o_al, o, p) then dockname+".setObjectAlign('"+o_id+"', "+jq_eudock_object_align_to_string(o_al)+", "+o+", "+jq_eudock_position_to_string(p)+");", jq_eudock_fixed_alignment(x, y, p) then dockname+".setPointAlign("+x+", "+y+", "+jq_eudock_position_to_string(p)+");" } // "+dockname+".setScreenAlign("+jq_eudock_position_to_string(position)+",0); . /* Creation of an euDock */ public define HTML_Partial_Content jquery_eudock ( JQ_euDock dock ) = with dockname="dock_"+now, // dock name is suffixed with a timestamp to guarantee its uniqueness if dock is jq_eudock(bar, icons, icon_offset, alignment) then partial_content ( [ js_inline(script("", " euEnv.imageBasePath=\"\"; var "+dockname+"=new euDock(); "+jquery_eudock_format_alignment(dockname, alignment)+" "+jquery_eudock_format_bar(dockname, bar)+" "+dockname+".setIconsOffset("+icon_offset+"); "+jquery_eudock_format_icons(dockname, icons)+" ")) ], literal("") // euDock does not need to return HTML content => it's javascript only ! ) .