From 4629b3421b4e7728dc1859a4752aa3d21d225483 Mon Sep 17 00:00:00 2001 From: Taka Date: Thu, 1 Sep 2022 18:13:39 +1000 Subject: [PATCH] Only show custom list bullets in the UI if they have been enabled. --- .../webapp/static/css/custom-bullets.css | 5 +++++ vasl_templates/webapp/static/css/html-editor.css | 6 +----- vasl_templates/webapp/static/user_settings.js | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 vasl_templates/webapp/static/css/custom-bullets.css diff --git a/vasl_templates/webapp/static/css/custom-bullets.css b/vasl_templates/webapp/static/css/custom-bullets.css new file mode 100644 index 0000000..e6bbe95 --- /dev/null +++ b/vasl_templates/webapp/static/css/custom-bullets.css @@ -0,0 +1,5 @@ +/* NOTE: This stylesheet will be dynamically injected into the UI when custom list bullets are enabled. */ +.trumbowyg-editor ul { list-style-image: url("../images/bullet.png") ; } +.trumbowyg-editor ul ul { list-style-image: url("../images/bullet2.png") ; } +.trumbowyg-editor ul ul ul { list-style-image: url("../images/bullet3.png") ; } +.trumbowyg-editor ol { list-style-image: none ; } diff --git a/vasl_templates/webapp/static/css/html-editor.css b/vasl_templates/webapp/static/css/html-editor.css index 0689d2a..60f38e0 100644 --- a/vasl_templates/webapp/static/css/html-editor.css +++ b/vasl_templates/webapp/static/css/html-editor.css @@ -7,12 +7,8 @@ .trumbowyg-button-group button::after { top: 25px !important ; } -/* custom bullets for the editor */ .trumbowyg-editor ul { margin: 0 0 0 0.9em ; } -.trumbowyg-editor ol { margin: 0 0 0 1.8em ; list-style-image: none ; } -.trumbowyg-editor ul { list-style-image: url("../images/bullet.png") ; } -.trumbowyg-editor ul ul { list-style-image: url("../images/bullet2.png") ; } -.trumbowyg-editor ul ul ul { list-style-image: url("../images/bullet3.png") ; } +.trumbowyg-editor ol { margin: 0 0 0 1.8em ; } /* make tables visible in the editor */ .trumbowyg-editor table.table { width: auto ; } diff --git a/vasl_templates/webapp/static/user_settings.js b/vasl_templates/webapp/static/user_settings.js index 5a2919d..669a16f 100644 --- a/vasl_templates/webapp/static/user_settings.js +++ b/vasl_templates/webapp/static/user_settings.js @@ -1,4 +1,5 @@ SCENARIO_IMAGES_SOURCE_THIS_PROGRAM = 1 ; + SCENARIO_IMAGES_SOURCE_INTERNET = 2 ; DEFAULT_USER_SETTINGS = { @@ -177,6 +178,21 @@ function apply_user_settings() $.datepicker.formatDate( date_format, curr_date ) ).trigger( "change" ) ; } + + // check if custom list bullets have been enabled + var $link = $( "head link[data-id='custom-bullets']" ) ; + if ( gUserSettings[ "custom-list-bullets" ] ) + { + // yup - inject our custom CSS into the UI to show them + if ( $link.length === 0 ) { + var url = make_app_url( "/static/css/custom-bullets.css" ) ; + $link = $( "" ) ; + $( "head" ).append( $link ) ; + } + } else { + // nope - remove our custom CSS + $link.remove() ; + } } // --------------------------------------------------------------------