template::CSS proc initialize (public)
template::CSS initialize
Defined in packages/xotcl-core/tcl/01-debug-procs.tcl
Initialize tailorization for CSS toolkits. The function reads the global apm package parameter and sets/resets accordingly (a) the default values (actually parameters) for the form field and (b) defines the toolkit specific CSS class name mapping. Loading optional, but universally present header files has do be performed per request... not sure this is the best place, since packages are as well initialized in the background.
- Testcases:
- No testcase defined.
Source code: # # Initialize tailorization for CSS toolkits. The function reads # the global apm package parameter and sets/resets accordingly # (a) the default values (actually parameters) for the form # field and (b) defines the toolkit specific CSS class name # mapping. # # # Loading optional, but universally present header files has do # be performed per request... not sure this is the best place, # since packages are as well initialized in the background. # if {[ns_conn isconnected] && [apm_package_enabled_p "bootstrap-icons"]} { template::head::add_css -href urn:ad:css:bootstrap-icons } set paramValue [parameter::get_global_value -package_key acs-templating -parameter PreferredCSSToolkit -default [parameter::get_global_value -package_key xowiki -parameter PreferredCSSToolkit -default default]] # # Check, if parameter value is compatible with the theme. In # particular, a preferred toolkit of "bootstrap3" does not work # when the theme is based on Bootstrap 5 and vice versa. When necessary, # align the value. # if {$paramValue in {default bootstrap bootstrap5} && [ns_conn isconnected]} { set theme [subsite::get_theme] if {$paramValue in {bootstrap default} && [string match *bootstrap5* $theme]} { set paramValue bootstrap5 } elseif {$paramValue in {bootstrap5 default} && [string match *bootstrap3* $theme]} { set paramValue bootstrap } if {$paramValue eq "default"} { # For the time being, YUI is the default (deriving default # toolkit from theme did not work, we have to assume that # the fonts for Bootstrap 3 or 5 are not loaded for edit # buttons, etc. set paramValue yui } } # # Just do initialization once # if {[info exists :preferredCSSToolkit] && ${:preferredCSSToolkit} eq $paramValue } { return } #ns_log notice "template::CSS: initialize to <$paramValue>" # # The code below is executed only on first initialization of the # object or on changes of the preferredCSSToolkit. # set :preferredCSSToolkit $paramValue set :iconset [template::iconset] if {${:preferredCSSToolkit} eq "bootstrap"} { if {[info commands ::xowiki::formfield::FormField] ne ""} { ::xowiki::formfield::FormField parameter [subst { {CSSclass form-control} {form_item_wrapper_CSSclass form-group} {form_label_CSSclass ""} {form_widget_CSSclass ""} {form_button_CSSclass "[template::CSS class form-action]"} {form_button_wrapper_CSSclass ""} {form_help_text_CSSclass help-block} }] } } elseif {${:preferredCSSToolkit} eq "bootstrap5"} { if {[info commands ::xowiki::formfield::FormField] ne ""} { ::xowiki::formfield::FormField parameter [subst { {CSSclass form-control} {form_item_wrapper_CSSclass mb-3} {form_label_CSSclass "form-label me-1"} {form_widget_CSSclass ""} {form_button_CSSclass "[template::CSS class form-action]"} {form_button_wrapper_CSSclass ""} {form_help_text_CSSclass form-text} }] ::xowiki::formfield::select parameter { {CSSclass form-select} } ::xowiki::formfield::checkbox parameter { {CSSclass form-check} } ::xowiki::formfield::radio parameter { {CSSclass form-check} } ::xowiki::formfield::range parameter { {CSSclass form-range} } } } else { if {[info commands ::xowiki::formfield::FormField] ne ""} { ::xowiki::formfield::FormField parameter { {CSSclass} {form_label_CSSclass ""} {form_widget_CSSclass form-widget} {form_item_wrapper_CSSclass form-item-wrapper} {form_button_CSSclass ""} {form_button_wrapper_CSSclass form-button} {form_help_text_CSSclass form-help-text} } ::xowiki::Form requireFormCSS } }XQL Not present: Generic, PostgreSQL, Oracle