From 09aeddee3814462e403090c571a5e23f991d70d8 Mon Sep 17 00:00:00 2001 From: yekolia Date: Thu, 13 Sep 2012 09:00:11 +0000 Subject: [PATCH] New: - Add 2 functions with more customizations for jQuery datatables. - Add 1 type for handling some options fir jQuery datatables. --- web/CXM_jquery_datatable.anubis | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ web/CXM_jquery_datatable_types.anubis | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 0 deletions(-) create mode 100644 web/CXM_jquery_datatable_types.anubis diff --git a/web/CXM_jquery_datatable.anubis b/web/CXM_jquery_datatable.anubis index f8b7b2f..6012a7a 100644 --- a/web/CXM_jquery_datatable.anubis +++ b/web/CXM_jquery_datatable.anubis @@ -9,6 +9,7 @@ read calexium_lib/web/CXM_making_a_web_site.anubis read calexium_lib/web/CXM_jquery.anubis +read calexium_lib/web/CXM_jquery_datatable_types.anubis read tools/basis.anubis read system/string.anubis @@ -39,3 +40,68 @@ public define HTML_Partial_Content table ) . + +public define HTML_Partial_Content + jquery_datatable + ( + String table_id, + HTML_Off_Form table, + Bool enable_jqueryui, + ) + = + if enable_jqueryui then + partial_content( + [ js_inline(script("", "$(document).ready(function(){$('#"+table_id+"').dataTable({\"bJQueryUI\":true});});")) ], + table + ) + else + jquery_datatable(table_id, table) + . + +public define String + bool_to_string + ( + Bool b + ) + = + if b then "true" else "false" + . + +public define HTML_Partial_Content + jquery_datatable + ( + String table_id, + HTML_Off_Form table, + Bool enable_jqueryui, + Bool enable_pagination, + JQuery_datatable_pagination_type pagination_type, + Bool enable_change_page_length, // if true, "enable_pagination" must be true too. + Bool enable_search_field, + Bool enable_columns_sorting + ) + = + partial_content( + [ + js_inline( + script( + "", + " + $(document).ready(function() + { + $('#"+table_id+"').dataTable( + { + \"bJQueryUI\":"+bool_to_string(enable_jqueryui)+", + \"sPaginationType\":'"+jquery_datatable_pagination_type_to_string(pagination_type)+"', + \"bFilter\":"+bool_to_string(enable_search_field)+", + \"bPaginate\":"+bool_to_string(enable_pagination)+", + \"bLengthChange\":"+bool_to_string(enable_change_page_length)+", + \"bSort\":"+bool_to_string(enable_columns_sorting)+" + }); + }); + " + ) + ) + ], + table + ) + . diff --git a/web/CXM_jquery_datatable_types.anubis b/web/CXM_jquery_datatable_types.anubis new file mode 100644 index 0000000..5960d5a --- /dev/null +++ b/web/CXM_jquery_datatable_types.anubis @@ -0,0 +1,42 @@ +/* + * Created by PyramIDE. + * User: Jeremy + * Date: 13/09/2012 + * Time: 10:12 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +read calexium_lib/web/CXM_making_a_web_site.anubis +read tools/basis.anubis +read system/string.anubis + +public type JQuery_datatable_pagination_type: + jq_dt_pt_two_button, //default option + jq_dt_pt_full_numbers +. + +public define String + jquery_datatable_pagination_type_to_string + ( + JQuery_datatable_pagination_type pt + ) + = + if pt is + { + jq_dt_pt_two_button then "two_button", + jq_dt_pt_full_numbers then "full_numbers" + } + . + +public define JQuery_datatable_pagination_type + string_to_jquery_datatable_pagination_type + ( + String str + ) + = + with st=to_lower(str), + if st="two_button" then jq_dt_pt_two_button else + if st="full_numbers" then jq_dt_pt_full_numbers else + jq_dt_pt_two_button + . -- libgit2 0.21.4