/* * Created by PyramIDE. * User: フランスのトトロ aka (David RENÉ) * Date: 20/02/2017 * Time: 04:31 * © David RENÉ */ read calexium_lib/web/CXM_making_a_web_site.anubis read calexium_lib/web/widgets/icons_set.anubis read calexium_lib/web/types/web_session.anubis public type Alignment: left, center, right. public type Page_Message: no_message, info(String message), info_translate(String message), ok(String message), ok_translate(String message), warning(String message), warning_translate(String message), error(String message, Alignment align), error_translate(String message, Alignment align). public define One set_Page_Message ( Var(List(WEB_Session_Field)) fields, Page_Message p_message )= with step = get_Int(fields, "AWS_SESSION_STEP",0), replace_Int(fields, "PAGE_MESSAGE_TTL", step+1); if p_message is { no_message then replace_String(fields, "PAGE_STATUS", "NO_MESSAGE"); replace_String(fields, "PAGE_MESSAGE", "") info(msg_str) then replace_String(fields, "PAGE_STATUS", "PAGE_INFO"); replace_String(fields, "PAGE_MESSAGE", msg_str) info_translate(msg_str) then replace_String(fields, "PAGE_STATUS", "PAGE_INFO_T"); replace_String(fields, "PAGE_MESSAGE", msg_str) ok(msg_str) then replace_String(fields, "PAGE_STATUS", "PAGE_OK"); replace_String(fields, "PAGE_MESSAGE", msg_str) ok_translate(msg_str) then replace_String(fields, "PAGE_STATUS", "PAGE_OK_T"); replace_String(fields, "PAGE_MESSAGE", msg_str) warning(msg_str) then replace_String(fields, "PAGE_STATUS", "PAGE_WARNING"); replace_String(fields, "PAGE_MESSAGE", msg_str) warning_translate(msg_str) then replace_String(fields, "PAGE_STATUS", "PAGE_WARNING_T"); replace_String(fields, "PAGE_MESSAGE", msg_str) error(msg_str, align) then replace_String(fields, "PAGE_STATUS", "PAGE_ERROR"); replace_String(fields, "PAGE_MESSAGE", msg_str) error_translate(msg_str, align) then replace_String(fields, "PAGE_STATUS", "PAGE_ERROR_T"); replace_String(fields, "PAGE_MESSAGE", msg_str) } . public define Page_Message error ( String message ) = error(message, left). public define Page_Message error_translate ( String message ) = error_translate(message, left). public define Page_Message get_Page_Message ( Var(List(WEB_Session_Field)) fields, (String) -> String _T )= with page_status = get_String(fields, "PAGE_STATUS", "NO_MESSAGE"), page_string = get_String(fields, "PAGE_MESSAGE", ""), page_ttl = get_Int(fields, "PAGE_MESSAGE_TTL", 0), step = get_Int(fields, "AWS_SESSION_STEP", 0), //the page Message is TimeOut. We remove it if page_ttl < step then remove_Int(fields, "PAGE_MESSAGE_TTL"); replace_String(fields, "PAGE_STATUS", "NO_MESSAGE"); replace_String(fields, "PAGE_MESSAGE", ""); no_message else if page_status = "NO_MESSAGE" then no_message else if page_status = "PAGE_INFO" then info(page_string) else if page_status = "PAGE_INFO_T" then info(_T(page_string)) else if page_status = "PAGE_OK" then ok(page_string) else if page_status = "PAGE_OK_T" then ok(_T(page_string)) else if page_status = "PAGE_WARNING" then warning(page_string) else if page_status = "PAGE_WARNING_T" then warning(_T(page_string)) else if page_status = "PAGE_ERROR" then error(page_string) else if page_status = "PAGE_ERROR_T" then error(_T(page_string)) else no_message . define List(CoreAttrs) get_info_line_attrbs ( String html_class, Alignment align ) = if align is { left then [class(html_class)], center then [class(html_class), style("margin-left: auto; margin-right: auto;")], right then [class(html_class), style("margin-left: auto;")] }. public define HTML_Off_Form hide_info_line_btn = div([event(onclick, "this.parentNode.style.display="none";"), style("width: 16px; height: 16px; background: transparent url(""+icn16_cross+"") no-repeat scroll center center; float: right; display: inline; cursor: pointer;")], literal("")). public define HTML_In_Form display_info_line ( String html_id, String html_class, String txt, Alignment align ) = div(get_info_line_attrbs(html_class, align), [partial(partial_content(hide_info_line_btn)), partial(partial_content(literal(txt)))]). public define HTML_Off_Form display_info_line ( String html_id, String html_class, String txt, Alignment align ) = div(get_info_line_attrbs(html_class, align), sequence([hide_info_line_btn, partial(partial_content(literal(txt)))])). public define HTML_Off_Form display_main_info_line ( String html_class, String txt, Alignment align ) = display_info_line("informations", html_class, txt, align). public define HTML_Off_Form display_main_info_line ( String html_class, String txt ) = display_info_line("informations", html_class, txt, left). public define HTML_Off_Form show_page_message ( Page_Message page_message )= if page_message is { no_message then empty, info(txt) then display_main_info_line("msg_infos", txt), info_translate(txt) then display_main_info_line("msg_infos", txt), ok(txt) then display_main_info_line("msg_success", txt), ok_translate(txt) then display_main_info_line("msg_success", txt), warning(txt) then display_main_info_line("msg_warning", txt), warning_translate(txt) then display_main_info_line("msg_warning", txt), error(txt, align) then display_main_info_line("msg_error",txt, align), error_translate(txt, align) then display_main_info_line("msg_error",txt, align), } .