From c420c168d1a49de513a993bff1cfa0eff8fb1de5 Mon Sep 17 00:00:00 2001 From: Taka Date: Thu, 28 Jul 2022 05:22:20 +1000 Subject: [PATCH] Added a WYSIWYG editor for HTML content. --- conftest.py | 7 +- vasl_templates/main_window.py | 5 +- vasl_templates/webapp/main.py | 45 +- .../static/css/edit-simple-note-dialog.css | 4 +- .../webapp/static/css/html-editor.css | 62 + vasl_templates/webapp/static/css/main.css | 3 + .../webapp/static/css/tabs-scenario.css | 2 +- vasl_templates/webapp/static/css/tabs.css | 2 +- vasl_templates/webapp/static/html-editor.js | 218 ++ .../player-colors.png => color-picker.png} | Bin .../static/images/trumbowyg/back-color.png | Bin 0 -> 438 bytes .../static/images/trumbowyg/fore-color.png | Bin 0 -> 435 bytes .../webapp/static/images/trumbowyg/smile.png | Bin 0 -> 3748 bytes .../webapp/static/jQueryHandlers.js | 2 +- vasl_templates/webapp/static/main.js | 26 +- vasl_templates/webapp/static/simple_notes.js | 47 +- vasl_templates/webapp/static/snippets.js | 38 +- .../webapp/static/trumbowyg/langs/ar.js | 67 + .../webapp/static/trumbowyg/langs/ar.min.js | 11 + .../webapp/static/trumbowyg/langs/bg.js | 54 + .../webapp/static/trumbowyg/langs/bg.min.js | 8 + .../webapp/static/trumbowyg/langs/bn.js | 62 + .../webapp/static/trumbowyg/langs/bn.min.js | 9 + .../webapp/static/trumbowyg/langs/by.js | 61 + .../webapp/static/trumbowyg/langs/by.min.js | 8 + .../webapp/static/trumbowyg/langs/ca.js | 57 + .../webapp/static/trumbowyg/langs/ca.min.js | 11 + .../webapp/static/trumbowyg/langs/cs.js | 63 + .../webapp/static/trumbowyg/langs/cs.min.js | 8 + .../webapp/static/trumbowyg/langs/da.js | 64 + .../webapp/static/trumbowyg/langs/da.min.js | 9 + .../webapp/static/trumbowyg/langs/de.js | 57 + .../webapp/static/trumbowyg/langs/de.min.js | 9 + .../webapp/static/trumbowyg/langs/el.js | 59 + .../webapp/static/trumbowyg/langs/el.min.js | 12 + .../webapp/static/trumbowyg/langs/es.js | 63 + .../webapp/static/trumbowyg/langs/es.min.js | 9 + .../webapp/static/trumbowyg/langs/es_ar.js | 56 + .../static/trumbowyg/langs/es_ar.min.js | 10 + .../webapp/static/trumbowyg/langs/et.js | 65 + .../webapp/static/trumbowyg/langs/et.min.js | 9 + .../webapp/static/trumbowyg/langs/fa.js | 58 + .../webapp/static/trumbowyg/langs/fa.min.js | 10 + .../webapp/static/trumbowyg/langs/fi.js | 58 + .../webapp/static/trumbowyg/langs/fi.min.js | 9 + .../webapp/static/trumbowyg/langs/fr.js | 66 + .../webapp/static/trumbowyg/langs/fr.min.js | 12 + .../webapp/static/trumbowyg/langs/he.js | 57 + .../webapp/static/trumbowyg/langs/he.min.js | 9 + .../webapp/static/trumbowyg/langs/hr.js | 54 + .../webapp/static/trumbowyg/langs/hr.min.js | 9 + .../webapp/static/trumbowyg/langs/hu.js | 58 + .../webapp/static/trumbowyg/langs/hu.min.js | 10 + .../webapp/static/trumbowyg/langs/id.js | 57 + .../webapp/static/trumbowyg/langs/id.min.js | 11 + .../webapp/static/trumbowyg/langs/it.js | 62 + .../webapp/static/trumbowyg/langs/it.min.js | 8 + .../webapp/static/trumbowyg/langs/ja.js | 63 + .../webapp/static/trumbowyg/langs/ja.min.js | 10 + .../webapp/static/trumbowyg/langs/ko.js | 66 + .../webapp/static/trumbowyg/langs/ko.min.js | 11 + .../webapp/static/trumbowyg/langs/lt.js | 59 + .../webapp/static/trumbowyg/langs/lt.min.js | 8 + .../webapp/static/trumbowyg/langs/mn.js | 49 + .../webapp/static/trumbowyg/langs/mn.min.js | 8 + .../webapp/static/trumbowyg/langs/my.js | 54 + .../webapp/static/trumbowyg/langs/my.min.js | 8 + .../webapp/static/trumbowyg/langs/nl.js | 61 + .../webapp/static/trumbowyg/langs/nl.min.js | 9 + .../webapp/static/trumbowyg/langs/no_nb.js | 56 + .../static/trumbowyg/langs/no_nb.min.js | 10 + .../webapp/static/trumbowyg/langs/ph.js | 54 + .../webapp/static/trumbowyg/langs/ph.min.js | 8 + .../webapp/static/trumbowyg/langs/pl.js | 55 + .../webapp/static/trumbowyg/langs/pl.min.js | 9 + .../webapp/static/trumbowyg/langs/pt.js | 65 + .../webapp/static/trumbowyg/langs/pt.min.js | 11 + .../webapp/static/trumbowyg/langs/pt_br.js | 65 + .../static/trumbowyg/langs/pt_br.min.js | 11 + .../webapp/static/trumbowyg/langs/ro.js | 58 + .../webapp/static/trumbowyg/langs/ro.min.js | 12 + .../webapp/static/trumbowyg/langs/rs.js | 53 + .../webapp/static/trumbowyg/langs/rs.min.js | 8 + .../webapp/static/trumbowyg/langs/rs_latin.js | 54 + .../static/trumbowyg/langs/rs_latin.min.js | 9 + .../webapp/static/trumbowyg/langs/ru.js | 61 + .../webapp/static/trumbowyg/langs/ru.min.js | 8 + .../webapp/static/trumbowyg/langs/sk.js | 54 + .../webapp/static/trumbowyg/langs/sk.min.js | 8 + .../webapp/static/trumbowyg/langs/sl.js | 56 + .../webapp/static/trumbowyg/langs/sl.min.js | 8 + .../webapp/static/trumbowyg/langs/sq.js | 65 + .../webapp/static/trumbowyg/langs/sq.min.js | 8 + .../webapp/static/trumbowyg/langs/sv.js | 58 + .../webapp/static/trumbowyg/langs/sv.min.js | 12 + .../webapp/static/trumbowyg/langs/th.js | 55 + .../webapp/static/trumbowyg/langs/th.min.js | 9 + .../webapp/static/trumbowyg/langs/tr.js | 63 + .../webapp/static/trumbowyg/langs/tr.min.js | 12 + .../webapp/static/trumbowyg/langs/ua.js | 54 + .../webapp/static/trumbowyg/langs/ua.min.js | 8 + .../webapp/static/trumbowyg/langs/vi.js | 56 + .../webapp/static/trumbowyg/langs/vi.min.js | 9 + .../webapp/static/trumbowyg/langs/zh_cn.js | 57 + .../static/trumbowyg/langs/zh_cn.min.js | 11 + .../webapp/static/trumbowyg/langs/zh_tw.js | 66 + .../static/trumbowyg/langs/zh_tw.min.js | 11 + .../trumbowyg.allowtagsfrompaste.js | 162 ++ .../trumbowyg.allowtagsfrompaste.min.js | 12 + .../plugins/base64/trumbowyg.base64.js | 171 ++ .../plugins/base64/trumbowyg.base64.min.js | 8 + .../cleanpaste/trumbowyg.cleanpaste.js | 147 ++ .../cleanpaste/trumbowyg.cleanpaste.min.js | 12 + .../plugins/colors/trumbowyg.colors.js | 275 +++ .../plugins/colors/trumbowyg.colors.min.js | 10 + .../colors/ui/sass/trumbowyg.colors.scss | 68 + .../plugins/colors/ui/trumbowyg.colors.css | 56 + .../colors/ui/trumbowyg.colors.min.css | 2 + .../plugins/emoji/trumbowyg.emoji.js | 1476 ++++++++++++ .../plugins/emoji/trumbowyg.emoji.min.js | 9 + .../emoji/ui/sass/trumbowyg.emoji.scss | 53 + .../plugins/emoji/ui/trumbowyg.emoji.css | 45 + .../plugins/emoji/ui/trumbowyg.emoji.min.css | 2 + .../webapp/static/trumbowyg/plugins/flags.css | 5 + .../webapp/static/trumbowyg/plugins/flags.js | 54 + .../fontfamily/trumbowyg.fontfamily.js | 107 + .../fontfamily/trumbowyg.fontfamily.min.js | 1 + .../plugins/fontsize/trumbowyg.fontsize.js | 340 +++ .../fontsize/trumbowyg.fontsize.min.js | 1 + .../plugins/giphy/trumbowyg.giphy.js | 197 ++ .../plugins/giphy/trumbowyg.giphy.min.js | 1 + .../giphy/ui/sass/trumbowyg.giphy.scss | 111 + .../plugins/giphy/ui/trumbowyg.giphy.css | 97 + .../plugins/giphy/ui/trumbowyg.giphy.min.css | 2 + .../plugins/highlight/trumbowyg.highlight.js | 319 +++ .../highlight/trumbowyg.highlight.min.js | 1 + .../ui/sass/trumbowyg.highlight.scss | 25 + .../highlight/ui/trumbowyg.highlight.css | 20 + .../highlight/ui/trumbowyg.highlight.min.css | 2 + .../plugins/history/trumbowyg.history.js | 246 ++ .../plugins/history/trumbowyg.history.min.js | 8 + .../plugins/indent/trumbowyg.indent.js | 78 + .../plugins/indent/trumbowyg.indent.min.js | 9 + .../insertaudio/trumbowyg.insertaudio.js | 109 + .../insertaudio/trumbowyg.insertaudio.min.js | 8 + .../lineheight/trumbowyg.lineheight.js | 198 ++ .../lineheight/trumbowyg.lineheight.min.js | 1 + .../plugins/mathml/trumbowyg.mathml.js | 149 ++ .../plugins/mathml/trumbowyg.mathml.min.js | 8 + .../mathml/ui/sass/trumbowyg.mathml.scss | 41 + .../plugins/mathml/ui/trumbowyg.mathml.css | 33 + .../mathml/ui/trumbowyg.mathml.min.css | 2 + .../plugins/mention/trumbowyg.mention.js | 125 + .../plugins/mention/trumbowyg.mention.min.js | 10 + .../mention/ui/sass/trumbowyg.mention.scss | 29 + .../plugins/mention/ui/trumbowyg.mention.css | 28 + .../mention/ui/trumbowyg.mention.min.css | 2 + .../plugins/noembed/trumbowyg.noembed.js | 132 ++ .../plugins/noembed/trumbowyg.noembed.min.js | 8 + .../pasteembed/trumbowyg.pasteembed.js | 96 + .../pasteembed/trumbowyg.pasteembed.min.js | 10 + .../pasteimage/trumbowyg.pasteimage.js | 49 + .../pasteimage/trumbowyg.pasteimage.min.js | 10 + .../preformatted/trumbowyg.preformatted.js | 151 ++ .../trumbowyg.preformatted.min.js | 8 + .../plugins/resizimg/trumbowyg.resizimg.js | 311 +++ .../resizimg/trumbowyg.resizimg.min.js | 3 + .../trumbowyg/plugins/ruby/trumbowyg.ruby.js | 114 + .../plugins/ruby/trumbowyg.ruby.min.js | 10 + .../specialchars/trumbowyg.specialchars.js | 94 + .../trumbowyg.specialchars.min.js | 8 + .../ui/sass/trumbowyg.specialchars.scss | 56 + .../ui/trumbowyg.specialchars.css | 48 + .../ui/trumbowyg.specialchars.min.css | 2 + .../plugins/table/trumbowyg.table.js | 454 ++++ .../plugins/table/trumbowyg.table.min.js | 8 + .../table/ui/sass/trumbowyg.table.scss | 46 + .../plugins/table/ui/trumbowyg.table.css | 38 + .../plugins/table/ui/trumbowyg.table.min.css | 2 + .../plugins/template/trumbowyg.template.js | 90 + .../template/trumbowyg.template.min.js | 1 + .../plugins/upload/trumbowyg.upload.js | 304 +++ .../plugins/upload/trumbowyg.upload.min.js | 13 + .../webapp/static/trumbowyg/trumbowyg.js | 2012 +++++++++++++++++ .../webapp/static/trumbowyg/trumbowyg.min.js | 2 + .../webapp/static/trumbowyg/ui/icons.svg | 1 + .../static/trumbowyg/ui/sass/trumbowyg.scss | 836 +++++++ .../webapp/static/trumbowyg/ui/trumbowyg.css | 640 ++++++ .../static/trumbowyg/ui/trumbowyg.min.css | 3 + .../static/trumbowyg/ui/trumbowyg.min.css.map | 2 + vasl_templates/webapp/static/vassal.js | 4 +- .../templates/edit-simple-note-dialog.html | 4 +- vasl_templates/webapp/templates/index.html | 18 + vasl_templates/webapp/templates/lfa.html | 2 +- .../webapp/templates/tabs-scenario.html | 4 +- .../webapp/tests/test_default_scenario.py | 11 +- .../tests/test_dirty_scenario_checks.py | 30 +- vasl_templates/webapp/tests/test_files.py | 5 +- vasl_templates/webapp/tests/test_ob.py | 12 +- .../webapp/tests/test_scenario_persistence.py | 11 +- vasl_templates/webapp/tests/test_snippets.py | 81 +- .../webapp/tests/test_template_packs.py | 6 +- .../webapp/tests/test_vehicles_ordnance.py | 4 +- vasl_templates/webapp/tests/utils.py | 92 +- 204 files changed, 14161 insertions(+), 103 deletions(-) create mode 100644 vasl_templates/webapp/static/css/html-editor.css create mode 100644 vasl_templates/webapp/static/html-editor.js rename vasl_templates/webapp/static/images/{lfa/player-colors.png => color-picker.png} (100%) create mode 100644 vasl_templates/webapp/static/images/trumbowyg/back-color.png create mode 100644 vasl_templates/webapp/static/images/trumbowyg/fore-color.png create mode 100644 vasl_templates/webapp/static/images/trumbowyg/smile.png create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/ar.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/ar.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/bg.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/bg.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/bn.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/bn.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/by.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/by.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/ca.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/ca.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/cs.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/cs.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/da.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/da.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/de.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/de.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/el.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/el.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/es.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/es.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/es_ar.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/es_ar.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/et.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/et.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/fa.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/fa.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/fi.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/fi.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/fr.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/fr.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/he.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/he.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/hr.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/hr.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/hu.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/hu.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/id.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/id.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/it.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/it.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/ja.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/ja.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/ko.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/ko.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/lt.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/lt.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/mn.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/mn.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/my.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/my.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/nl.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/nl.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/no_nb.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/no_nb.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/ph.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/ph.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/pl.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/pl.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/pt.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/pt.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/pt_br.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/pt_br.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/ro.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/ro.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/rs.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/rs.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/rs_latin.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/rs_latin.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/ru.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/ru.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/sk.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/sk.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/sl.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/sl.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/sq.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/sq.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/sv.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/sv.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/th.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/th.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/tr.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/tr.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/ua.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/ua.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/vi.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/vi.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/zh_cn.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/zh_cn.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/zh_tw.js create mode 100644 vasl_templates/webapp/static/trumbowyg/langs/zh_tw.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/allowtagsfrompaste/trumbowyg.allowtagsfrompaste.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/allowtagsfrompaste/trumbowyg.allowtagsfrompaste.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/base64/trumbowyg.base64.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/base64/trumbowyg.base64.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/cleanpaste/trumbowyg.cleanpaste.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/cleanpaste/trumbowyg.cleanpaste.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/colors/trumbowyg.colors.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/colors/trumbowyg.colors.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/colors/ui/sass/trumbowyg.colors.scss create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/colors/ui/trumbowyg.colors.css create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/colors/ui/trumbowyg.colors.min.css create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/emoji/trumbowyg.emoji.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/emoji/trumbowyg.emoji.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/emoji/ui/sass/trumbowyg.emoji.scss create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/emoji/ui/trumbowyg.emoji.css create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/emoji/ui/trumbowyg.emoji.min.css create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/flags.css create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/flags.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/fontfamily/trumbowyg.fontfamily.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/fontfamily/trumbowyg.fontfamily.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/fontsize/trumbowyg.fontsize.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/fontsize/trumbowyg.fontsize.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/giphy/trumbowyg.giphy.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/giphy/trumbowyg.giphy.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/giphy/ui/sass/trumbowyg.giphy.scss create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/giphy/ui/trumbowyg.giphy.css create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/giphy/ui/trumbowyg.giphy.min.css create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/highlight/trumbowyg.highlight.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/highlight/trumbowyg.highlight.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/highlight/ui/sass/trumbowyg.highlight.scss create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/highlight/ui/trumbowyg.highlight.css create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/highlight/ui/trumbowyg.highlight.min.css create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/history/trumbowyg.history.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/history/trumbowyg.history.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/indent/trumbowyg.indent.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/indent/trumbowyg.indent.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/insertaudio/trumbowyg.insertaudio.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/insertaudio/trumbowyg.insertaudio.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/lineheight/trumbowyg.lineheight.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/lineheight/trumbowyg.lineheight.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/mathml/trumbowyg.mathml.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/mathml/trumbowyg.mathml.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/mathml/ui/sass/trumbowyg.mathml.scss create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/mathml/ui/trumbowyg.mathml.css create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/mathml/ui/trumbowyg.mathml.min.css create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/mention/trumbowyg.mention.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/mention/trumbowyg.mention.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/mention/ui/sass/trumbowyg.mention.scss create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/mention/ui/trumbowyg.mention.css create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/mention/ui/trumbowyg.mention.min.css create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/noembed/trumbowyg.noembed.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/noembed/trumbowyg.noembed.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/pasteembed/trumbowyg.pasteembed.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/pasteembed/trumbowyg.pasteembed.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/preformatted/trumbowyg.preformatted.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/preformatted/trumbowyg.preformatted.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/resizimg/trumbowyg.resizimg.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/resizimg/trumbowyg.resizimg.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/ruby/trumbowyg.ruby.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/ruby/trumbowyg.ruby.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/specialchars/trumbowyg.specialchars.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/specialchars/trumbowyg.specialchars.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/specialchars/ui/sass/trumbowyg.specialchars.scss create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/specialchars/ui/trumbowyg.specialchars.css create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/specialchars/ui/trumbowyg.specialchars.min.css create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/table/trumbowyg.table.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/table/trumbowyg.table.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/table/ui/sass/trumbowyg.table.scss create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/table/ui/trumbowyg.table.css create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/table/ui/trumbowyg.table.min.css create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/template/trumbowyg.template.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/template/trumbowyg.template.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/upload/trumbowyg.upload.js create mode 100644 vasl_templates/webapp/static/trumbowyg/plugins/upload/trumbowyg.upload.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/trumbowyg.js create mode 100644 vasl_templates/webapp/static/trumbowyg/trumbowyg.min.js create mode 100644 vasl_templates/webapp/static/trumbowyg/ui/icons.svg create mode 100644 vasl_templates/webapp/static/trumbowyg/ui/sass/trumbowyg.scss create mode 100644 vasl_templates/webapp/static/trumbowyg/ui/trumbowyg.css create mode 100644 vasl_templates/webapp/static/trumbowyg/ui/trumbowyg.min.css create mode 100644 vasl_templates/webapp/static/trumbowyg/ui/trumbowyg.min.css.map diff --git a/conftest.py b/conftest.py index aaa0dea..7d6b961 100644 --- a/conftest.py +++ b/conftest.py @@ -42,7 +42,7 @@ def pytest_addoption( parser ): help="Run the tests headless." ) parser.addoption( - "--window-size", action="store", dest="window_size", default="1000x700", + "--window-size", action="store", dest="window_size", default="1020x700", help="Browser window size." ) @@ -184,6 +184,11 @@ def _make_webapp(): elif _pytest_options.webdriver == "chrome": app.config[ "WEBDRIVER_PATH" ] = "chromedriver" + # NOTE: Trumboyg adds a lot of buttons to the UI, which slows Selenium down a lot + # when it's searching for elements, so we run tests with a minimal configuration. + app.config[ "TRUMBOWYG_BUTTONS_VICTORY_CONDITIONS" ] = [ "viewHTML" ] + app.config[ "TRUMBOWYG_BUTTONS_SIMPLE_NOTE_DIALOG" ] = [ "viewHTML" ] + return app # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/vasl_templates/main_window.py b/vasl_templates/main_window.py index f06ccbd..2798202 100644 --- a/vasl_templates/main_window.py +++ b/vasl_templates/main_window.py @@ -94,7 +94,10 @@ class MainWindow( QWidget ): self.restoreGeometry( val ) else : self.resize( 1000, 650 ) - self.setMinimumSize( 1015, 630 ) + # NOTE: This should be wide enough for the sortable hints to not wrap (so that + # we don't see a scrollbar when their panels are reduced to their minimum height). + # We also want the Trumbowyg button pane for the VC to wrap somewhere sensible. + self.setMinimumSize( 1030, 630 ) # initialize the layout layout = QVBoxLayout( self ) diff --git a/vasl_templates/webapp/main.py b/vasl_templates/webapp/main.py index a5606f1..8dfb6eb 100644 --- a/vasl_templates/webapp/main.py +++ b/vasl_templates/webapp/main.py @@ -86,7 +86,9 @@ def get_app_config(): """Get a JSON value from the app config.""" try: val = app.config.get( key, default ) - return val if isinstance(val,dict) else json.loads(val) + if isinstance( val, (dict,list) ): + return val + return json.loads( val ) except json.decoder.JSONDecodeError: msg = "Couldn't parse app config setting: {}".format( key ) logging.error( "%s", msg ) @@ -160,6 +162,47 @@ def get_app_config(): logging.error( "%s", msg ) startup_msg_store.error( msg ) + # include the Trumbowyg config + # NOTE: We don't include the "insertImage" button because it doesn't seem to work when + # the Trumbowyg control is in a dialog, and given VASSAL's handling of images, we don't + # really want to be encouraging their use :-/ + vals[ "trumbowyg" ] = { + "format-options": get_json_val( "TRUMBOWYG_FORMAT_OPTIONS", [ + "h1", "h2", "h3", + ] ), + "special-chars": get_json_val( "TRUMBOWYG_SPECIAL_CHARS", [ + "2264", "2265", "2260", "00d7", "00f7", None, # math + "00bd", "00bc", "00be", "215b", "215c", "215d", "215e", None, # fractions + "25b3", "24c7", "24b7", "24ba", "2605", "221e", "b0", "b7", None, # special + "e4", "eb", "ef", "f6", "fc", "c4", "cb", "cf", "d6", "dc", None, # umlaut + "e1", "e9", "ed", "f3", "fa", "c1", "c9", "cd", "d3", "da", None, # acute + "e0", "e8", "ec", "f2", "f9", "c0", "c8", "cc", "d2", "d9", None, # grave + "e2", "ea", "ee", "f4", "fb", "c2", "ca", "ce", "d4", "db", None, # circumflex + "1f850", "1f852", "1f851", "1f853", # arrows + ] ), + "victory-conditions": get_json_val( "TRUMBOWYG_BUTTONS_VICTORY_CONDITIONS", [ + [ "strong", "em", "underline", "superscript", "subscript", "format" ], + [ "foreColor", "backColor", "fontfamily", "fontsize" ], + [ "outdent", "indent" ], + [ "unorderedList", "orderedList", "table" ], + [ "specialChars", "flags", "emoji" ], + [ "removeformat", "historyUndo", "historyRedo", "viewHTML", "fullscreen" ], + ] ), + # NOTE: I tried having different buttons for OB setup notes (which tend to be simpler) + # and OB notes (which can be more involved), but (1) this meant we had to tear down + # and re-create the Trumbowyg control each time the dialog was opened (since there doesn't + # seem to be any way to dynamically change the buttons), which caused a noticeable delay, + # and (2) users are probaly going to complain :-/ + "simple-note-dialog": get_json_val( "TRUMBOWYG_BUTTONS_SIMPLE_NOTE_DIALOG", [ + [ "strong", "em", "underline", "del", "superscript", "subscript", "format" ], + [ "foreColor", "backColor", "fontfamily", "fontsize" ], + [ "align", "outdent", "indent" ], + [ "unorderedList", "orderedList", "table" ], + [ "specialChars", "flags", "emoji" ], + [ "removeformat", "historyUndo", "historyRedo", "viewHTML", "fullscreen" ], + ] ), + } + return jsonify( vals ) # --------------------------------------------------------------------- diff --git a/vasl_templates/webapp/static/css/edit-simple-note-dialog.css b/vasl_templates/webapp/static/css/edit-simple-note-dialog.css index a696682..fb2dfe0 100644 --- a/vasl_templates/webapp/static/css/edit-simple-note-dialog.css +++ b/vasl_templates/webapp/static/css/edit-simple-note-dialog.css @@ -1,6 +1,6 @@ -#edit-simple_note { overflow: hidden ; } +#edit-simple_note { overflow: hidden ; padding-bottom: 0.75em !important ; } .ui-dialog.edit-simple_note .ui-dialog-buttonpane { border: none ; margin-top: 0 !important ; padding-top: 0 !important ; } -.ui-dialog.edit-simple_note textarea { resize: none ; width: calc(100% - 4px) ; height: 100% ; } +.ui-dialog.edit-simple_note .container { height: 100% ; display: flex ; flex-direction: row ; } .ui-dialog.edit-simple_note label[for="width"] { color: #444 ; } .ui-dialog.edit-simple_note input[name="width"] { color: #444 ; } diff --git a/vasl_templates/webapp/static/css/html-editor.css b/vasl_templates/webapp/static/css/html-editor.css new file mode 100644 index 0000000..9fc19db --- /dev/null +++ b/vasl_templates/webapp/static/css/html-editor.css @@ -0,0 +1,62 @@ +.trumbowyg-box { min-height: 2em ; border-color: #ccc ; } + +.trumbowyg-editor, .trumbowyg-textarea { + padding: 0.5em 0.75em ; + min-height: 2em ; +} + +.trumbowyg-button-group button::after { top: 25px !important ; } + +/* custom bullets for the editor */ +.trumbowyg-editor ul { margin: 0 0 0 0.85em ; list-style-image: url("../images/bullet.png") ; } +.trumbowyg-editor ul ul { margin: 0 0 0 0.85em ; list-style-image: url("../images/bullet2.png") ; } +.trumbowyg-editor ul ul ul { margin: 0 0 0 0.85em ; list-style-image: url("../images/bullet3.png") ; } + +/* make tables visible in the editor */ +.trumbowyg-editor table.table { width: auto ; } +.trumbowyg-editor table.table td { border: 1px dotted #888 ; } + +/* FUDGE! CSS for blockquote doesn't work in VASSAL :-/, so we try to match its indent in our UI. */ +.trumbowyg-editor blockquote { margin-left: 2.5em ; } + +/* modal box */ +.trumbowyg-modal-box { border: 1px solid #666 ; } +.trumbowyg-modal-box .trumbowyg-input-infos label { color: #444 ; font-weight: bold ; } + +/* configure button */ +.trumbowyg-foreColor-button { + width: 40px !important ; + background: no-repeat 12px 12px url("../images/trumbowyg/fore-color.png") !important ; + background-size: 12px 12px !important ; + filter: grayscale(100%) brightness(90%) ; +} +.trumbowyg-backColor-button { + width: 40px !important ; + background: no-repeat 12px 12px url("../images/trumbowyg/back-color.png") !important ; + background-size: 12px 12px !important ; + filter: grayscale(100%) brightness(90%) ; +} +.trumbowyg-emoji-button { + width: 40px !important ; + background: no-repeat 13px 13px url("../images/trumbowyg/smile.png") !important ; + background-size: 12px 12px !important ; + filter: grayscale(100%) brightness(40%) ; +} +.trumbowyg-removeformat-button { line-height: 33px !important ; border:1px dotted red; } +.trumbowyg-dropdown-specialChars { width: 330px ; max-width: 330px ; } +.trumbowyg-dropdown-align { max-height: 160px !important ; } + +/* configure an image for our custom "flags" button */ +.trumbowyg-flags-button { + width: 40px !important ; + background: no-repeat 12px 13px url("../images/nat-caps.png") !important ; + background-size: 12px 12px !important ; + filter: grayscale(100%) brightness(60%) ; +} +.trumbowyg-dropdown-flags button img { width: 13px ; } + +/* FUDGE! Fix-up the appearance of some of the buttons. */ +.trumbowyg-fontsize-button svg { width: 14px ; opacity: 0.9 ; } +.Xtrumbowyg-specialChars-button { color: #555 ; } +.trumbowyg-indent-button svg, .trumbowyg-outdent-button svg { width: 13px ; } +.trumbowyg-indent-button svg { transform: scaleX(-1) ; } diff --git a/vasl_templates/webapp/static/css/main.css b/vasl_templates/webapp/static/css/main.css index 0720c25..5ea8fef 100644 --- a/vasl_templates/webapp/static/css/main.css +++ b/vasl_templates/webapp/static/css/main.css @@ -4,6 +4,7 @@ body { height: 100% ; overflow: hidden ; } body { font-family: Arial, Helvetica, sans-serif ; font-size: 16px ; } +p { margin-bottom: 0.5em ; } ul, ol { margin: 0.5em 0 0 1.25em ; } input[type="text"] { height: 20px ; border: 1px solid #c5c5c5 ; padding: 0 2px ; } @@ -58,11 +59,13 @@ input.snippet-width { width: 3.75em ; } .sp-palette { max-width: 120px ; } .sp-palette-row-selection { margin-top: 6px ; border-top: 1px solid #ccc ; padding-top: 6px ; } +/* growl notification balloons */ .growl-title { display: none ; } .growl-close { position: absolute ; top: 0 ; right: 5px ; } .growl .pre { font-family: monospace ; } .growl div.pre { margin: 0 0 1em 1em ; font-size: 80% ; } +/* splitters */ .gutter { position: relative ; background-color: #ddd ; } .gutter-vertical { cursor: row-resize ; } .gutter-horizontal { cursor: col-resize ; } diff --git a/vasl_templates/webapp/static/css/tabs-scenario.css b/vasl_templates/webapp/static/css/tabs-scenario.css index 5416024..4df7f1f 100644 --- a/vasl_templates/webapp/static/css/tabs-scenario.css +++ b/vasl_templates/webapp/static/css/tabs-scenario.css @@ -33,7 +33,7 @@ fieldset[name='scenario'] { min-height: 91px ; max-height: 265px ; overflow: hid /* -------------------------------------------------------------------- */ #panel-vc { height: 100% ; display: flex ; flex-direction: column ; } -#panel-vc textarea { width: 100% ; resize: none ; flex-grow: 1 ; } +#panel-vc .trumbowyg-box { flex-grow: 1 ; min-height: 100px ; width: calc(100% - 2px) ; } #panel-vc .footer { margin-top: 0.5em ; display: flex ; align-items: center ; } /* -------------------------------------------------------------------- */ diff --git a/vasl_templates/webapp/static/css/tabs.css b/vasl_templates/webapp/static/css/tabs.css index e246537..31c4918 100644 --- a/vasl_templates/webapp/static/css/tabs.css +++ b/vasl_templates/webapp/static/css/tabs.css @@ -27,7 +27,7 @@ #tabs-scenario .bl { height: 100% ; flex-grow: 1 ; } #tabs-scenario .right { display: flex ; flex-direction: column ; } -#tabs-scenario .tr { height: 100% ; flex-grow: 1 ; } +#tabs-scenario .tr { height: 100% ; min-height: 210px ; flex-grow: 1 ; } #tabs-scenario .br { height: 100% ; flex-grow: 1 ; min-height: 9em ; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ diff --git a/vasl_templates/webapp/static/html-editor.js b/vasl_templates/webapp/static/html-editor.js new file mode 100644 index 0000000..7b0c84c --- /dev/null +++ b/vasl_templates/webapp/static/html-editor.js @@ -0,0 +1,218 @@ +// -------------------------------------------------------------------- + +function initTrumbowyg( $elem, buttons, $parentDlg ) +{ + // initialize + var nats = get_sorted_nats().filter( + function( nat ) { return gHasPlayerFlag[ nat ] ; } + ) ; + + // initialize the Trumbowyg control + // NOTE: Trumbowyg uses the
we supply as the WYSIWYG editor, and creates an associated ', + '
', + buildLineHighlightFieldIfEnabled(trumbowyg), + ].join('\n')), + $language = $modal.find('.language'), + $code = $modal.find('.code'), + $lineHighlight = $modal.find('.trumbowyg-line-highlight'); + + // Listen clicks on modal box buttons + $modal.on('tbwconfirm', function () { + trumbowyg.restoreRange(); + trumbowyg.execCmd('insertHTML', highlightIt($code.val(), $language.val(), $lineHighlight.val())); + trumbowyg.execCmd('insertHTML', '


'); + + trumbowyg.closeModal(); + }); + + $modal.on('tbwcancel', function () { + trumbowyg.closeModal(); + }); + } + }; + } + + $.extend(true, $.trumbowyg, { + // Add some translations + langs: { + // jshint camelcase:false + en: { + highlight: 'Code syntax highlight', + highlightLine: 'Highlight lines, e.g.: 1,3-5' + }, + by: { + highlight: 'Падсветка сінтаксісу кода', + highlightLine: 'Падсвятліць радкі, напр.: 1,3-5' + }, + es: { + highlight: 'Resaltado de sintaxis de código', + highlightLine: 'Resaltar lineas, ej: 1,3-5' + }, + et: { + highlight: 'Koodi esiletoomine', + highlightLine: 'Koodiread, näiteks: 1,3-5' + }, + hu: { + highlight: 'Kód kiemelés' + }, + ko: { + highlight: '코드 문법 하이라이트' + }, + pt_br: { + highlight: 'Realçar sintaxe de código' + }, + ru: { + highlight: 'Подсветка синтаксиса кода', + highlightLine: 'Подсветить строки, напр.: 1,3-5' + }, + tr: { + highlight: 'Kod sözdizimini vurgula', + highlightLine: 'Vurgu çizgileri, örneğin: 1,3-5' + }, + // jshint camelcase:true + }, + // Add our plugin to Trumbowyg registered plugins + plugins: { + highlight: { + init: function (trumbowyg) { + // Fill current Trumbowyg instance with my plugin default options + trumbowyg.o.plugins.highlight = $.extend(true, {}, + defaultOptions, + trumbowyg.o.plugins.highlight || {} + ); + + // If my plugin is a button + trumbowyg.addBtnDef('highlight', buildButtonDef(trumbowyg)); + } + } + } + }); +})(jQuery, Prism); diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/highlight/trumbowyg.highlight.min.js b/vasl_templates/webapp/static/trumbowyg/plugins/highlight/trumbowyg.highlight.min.js new file mode 100644 index 0000000..d475f1c --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/highlight/trumbowyg.highlight.min.js @@ -0,0 +1 @@ +!function(e,i){"use strict";var t={enableLineHighlight:!0,languageNames:{html:"HTML",xml:"XML",svg:"SVG",mathml:"MathML",ssml:"SSML",css:"CSS",clike:"C-like",js:"JavaScript",abap:"ABAP",abnf:"Augmented Backus–Naur form",al:"AL",antlr4:"ANTLR4",g4:"ANTLR4",apacheconf:"Apache Configuration",apl:"APL",aql:"AQL",arff:"ARFF",asciidoc:"AsciiDoc",adoc:"AsciiDoc",asm6502:"6502 Assembly",aspnet:"ASP.NET (C#)",autohotkey:"AutoHotkey",autoit:"AutoIt",basic:"BASIC",bbcode:"BBcode",bnf:"Backus–Naur form",rbnf:"Routing Backus–Naur form",conc:"Concurnas",csharp:"C#",cs:"C#",dotnet:"C#",cpp:"C++",cil:"CIL",coffee:"CoffeeScript",cmake:"CMake",csp:"Content-Security-Policy","css-extras":"CSS Extras",dax:"DAX",django:"Django/Jinja2",jinja2:"Django/Jinja2","dns-zone-file":"DNS zone file","dns-zone":"DNS zone file",dockerfile:"Docker",ebnf:"Extended Backus–Naur form",ejs:"EJS",etlua:"Embedded Lua templating",erb:"ERB","excel-formula":"Excel Formula",xlsx:"Excel Formula",xls:"Excel Formula",fsharp:"F#","firestore-security-rules":"Firestore security rules",ftl:"FreeMarker Template Language",gcode:"G-code",gdscript:"GDScript",gedcom:"GEDCOM",glsl:"GLSL",gml:"GameMaker Language",gamemakerlanguage:"GameMaker Language",graphql:"GraphQL",hs:"Haskell",hcl:"HCL",hlsl:"HLSL",http:"HTTP",hpkp:"HTTP Public-Key-Pins",hsts:"HTTP Strict-Transport-Security",ichigojam:"IchigoJam",iecst:"Structured Text (IEC 61131-3)",inform7:"Inform 7",javadoc:"JavaDoc",javadoclike:"JavaDoc-like",javastacktrace:"Java stack trace",jq:"JQ",jsdoc:"JSDoc","js-extras":"JS Extras","js-templates":"JS Templates",json:"JSON",jsonp:"JSONP",json5:"JSON5",latex:"LaTeX",tex:"TeX",context:"ConTeXt",lilypond:"LilyPond",ly:"LilyPond",emacs:"Lisp",elisp:"Lisp","emacs-lisp":"Lisp",llvm:"LLVM IR",lolcode:"LOLCODE",md:"Markdown","markup-templating":"Markup templating",matlab:"MATLAB",mel:"MEL",moon:"MoonScript",n1ql:"N1QL",n4js:"N4JS",n4jsd:"N4JS","nand2tetris-hdl":"Nand To Tetris HDL",nasm:"NASM",neon:"NEON",nginx:"nginx",nsis:"NSIS",objectivec:"Objective-C",objc:"Objective-C",ocaml:"OCaml",opencl:"OpenCL",parigp:"PARI/GP",objectpascal:"Object Pascal",pcaxis:"PC-Axis",px:"PC-Axis",peoplecode:"PeopleCode",pcode:"PeopleCode",php:"PHP",phpdoc:"PHPDoc","php-extras":"PHP Extras",plsql:"PL/SQL",powerquery:"PowerQuery",pq:"PowerQuery",mscript:"PowerQuery",powershell:"PowerShell",properties:".properties",protobuf:"Protocol Buffers",py:"Python",q:"Q (kdb+ database)",qml:"QML",rkt:"Racket",jsx:"React JSX",tsx:"React TSX",renpy:"Ren'py",rest:"reST (reStructuredText)",robotframework:"Robot Framework",robot:"Robot Framework",rb:"Ruby",sas:"SAS",sass:"Sass (Sass)",scss:"Sass (Scss)","shell-session":"Shell session",solidity:"Solidity (Ethereum)","solution-file":"Solution file",sln:"Solution file",soy:"Soy (Closure Template)",sparql:"SPARQL",rq:"SPARQL","splunk-spl":"Splunk SPL",sqf:"SQF: Status Quo Function (Arma 3)",sql:"SQL",tap:"TAP",toml:"TOML",tt2:"Template Toolkit 2",trig:"TriG",ts:"TypeScript","t4-cs":"T4 Text Templates (C#)",t4:"T4 Text Templates (C#)","t4-vb":"T4 Text Templates (VB)","t4-templating":"T4 templating",uscript:"UnrealScript",uc:"UnrealScript",vbnet:"VB.Net",vhdl:"VHDL",vim:"vim","visual-basic":"Visual Basic",vb:"Visual Basic",wasm:"WebAssembly",wiki:"Wiki markup",xeoracube:"XeoraCube",xojo:"Xojo (REALbasic)",xquery:"XQuery",yaml:"YAML",yml:"YAML"}};function a(i){return e("
").text(i).html()}function o(e){var t=e.o.plugins.highlight.languageNames,o=Object.keys(t);return Object.keys(i.languages).filter((function(e){return o.indexOf(e)>=0})).map((function(e){return{id:e,name:t[e]}})).sort((function(e,i){return e.name.localeCompare(i.name)})).map((function(e){return'"})).join("")}function l(e){return!1===e.o.plugins.highlight.enableLineHighlight?"":'
'}function s(e){return{fn:function(){var t=e.openModal("Code",['
',' ","
",'
',' ',"
",l(e)].join("\n")),a=t.find(".language"),s=t.find(".code"),n=t.find(".trumbowyg-line-highlight");t.on("tbwconfirm",(function(){var t,o,l;e.restoreRange(),e.execCmd("insertHTML",(t=s.val(),o=a.val(),l=n.val(),['
",''+i.highlight(t,i.languages[o])+"","
"].join(""))),e.execCmd("insertHTML","


"),e.closeModal()})),t.on("tbwcancel",(function(){e.closeModal()}))}}}e.extend(!0,e.trumbowyg,{langs:{en:{highlight:"Code syntax highlight",highlightLine:"Highlight lines, e.g.: 1,3-5"},by:{highlight:"Падсветка сінтаксісу кода",highlightLine:"Падсвятліць радкі, напр.: 1,3-5"},es:{highlight:"Resaltado de sintaxis de código",highlightLine:"Resaltar lineas, ej: 1,3-5"},et:{highlight:"Koodi esiletoomine",highlightLine:"Koodiread, näiteks: 1,3-5"},hu:{highlight:"Kód kiemelés"},ko:{highlight:"코드 문법 하이라이트"},pt_br:{highlight:"Realçar sintaxe de código"},ru:{highlight:"Подсветка синтаксиса кода",highlightLine:"Подсветить строки, напр.: 1,3-5"},tr:{highlight:"Kod sözdizimini vurgula",highlightLine:"Vurgu çizgileri, örneğin: 1,3-5"}},plugins:{highlight:{init:function(i){i.o.plugins.highlight=e.extend(!0,{},t,i.o.plugins.highlight||{}),i.addBtnDef("highlight",s(i))}}}})}(jQuery,Prism); \ No newline at end of file diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/highlight/ui/sass/trumbowyg.highlight.scss b/vasl_templates/webapp/static/trumbowyg/plugins/highlight/ui/sass/trumbowyg.highlight.scss new file mode 100644 index 0000000..5fb95e4 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/highlight/ui/sass/trumbowyg.highlight.scss @@ -0,0 +1,25 @@ +/** + * Trumbowyg v2.25.2 - A lightweight WYSIWYG editor + * Default stylesheet for Trumbowyg editor plugin + * ------------------------ + * @link http://alex-d.github.io/Trumbowyg + * @license MIT + * @author Alexandre Demode (Alex-D) + * Twitter : @AlexandreDemode + * Website : alex-d.fr + */ + +.trumbowyg-highlight-form-group { + margin: 15px 10px; + + .trumbowyg-highlight-form-control { + width: 100%; + border: 1px solid #DEDEDE; + font-size: 14px; + padding: 7px; + + &.code { + height: 200px; + } + } +} diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/highlight/ui/trumbowyg.highlight.css b/vasl_templates/webapp/static/trumbowyg/plugins/highlight/ui/trumbowyg.highlight.css new file mode 100644 index 0000000..48b82b8 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/highlight/ui/trumbowyg.highlight.css @@ -0,0 +1,20 @@ +/** + * Trumbowyg v2.25.2 - A lightweight WYSIWYG editor + * Trumbowyg plugin stylesheet + * ------------------------ + * @link http://alex-d.github.io/Trumbowyg + * @license MIT + * @author Alexandre Demode (Alex-D) + * Twitter : @AlexandreDemode + * Website : alex-d.fr + */ + +.trumbowyg-highlight-form-group { + margin: 15px 10px; } + .trumbowyg-highlight-form-group .trumbowyg-highlight-form-control { + width: 100%; + border: 1px solid #DEDEDE; + font-size: 14px; + padding: 7px; } + .trumbowyg-highlight-form-group .trumbowyg-highlight-form-control.code { + height: 200px; } diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/highlight/ui/trumbowyg.highlight.min.css b/vasl_templates/webapp/static/trumbowyg/plugins/highlight/ui/trumbowyg.highlight.min.css new file mode 100644 index 0000000..ab75f00 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/highlight/ui/trumbowyg.highlight.min.css @@ -0,0 +1,2 @@ +/** Trumbowyg v2.25.2 - A lightweight WYSIWYG editor - alex-d.github.io/Trumbowyg - License MIT - Author : Alexandre Demode (Alex-D) / alex-d.fr */ +.trumbowyg-highlight-form-group{margin:15px 10px}.trumbowyg-highlight-form-group .trumbowyg-highlight-form-control{width:100%;border:1px solid #DEDEDE;font-size:14px;padding:7px}.trumbowyg-highlight-form-group .trumbowyg-highlight-form-control.code{height:200px} \ No newline at end of file diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/history/trumbowyg.history.js b/vasl_templates/webapp/static/trumbowyg/plugins/history/trumbowyg.history.js new file mode 100644 index 0000000..9a9322f --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/history/trumbowyg.history.js @@ -0,0 +1,246 @@ +/*/* =========================================================== + * trumbowyg.history.js v1.0 + * history plugin for Trumbowyg + * http://alex-d.github.com/Trumbowyg + * =========================================================== + * Author : Sven Dunemann [dunemann@forelabs.eu] + */ + +(function ($) { + 'use strict'; + $.extend(true, $.trumbowyg, { + langs: { + // jshint camelcase:false + en: { + history: { + redo: 'Redo', + undo: 'Undo' + } + }, + by: { + history: { + redo: 'Паўтарыць', + undo: 'Скасаваць' + } + }, + da: { + history: { + redo: 'Annuller fortryd', + undo: 'Fortryd' + } + }, + de: { + history: { + redo: 'Wiederholen', + undo: 'Rückgängig' + } + }, + et: { + history: { + redo: 'Võta tagasi', + undo: 'Tee uuesti' + } + }, + fr: { + history: { + redo: 'Annuler', + undo: 'Rétablir' + } + }, + hu: { + history: { + redo: 'Visszállít', + undo: 'Visszavon' + } + }, + ko: { + history: { + redo: '다시 실행', + undo: '되돌리기' + } + }, + pt_br: { + history: { + redo: 'Refazer', + undo: 'Desfazer' + } + }, + ru: { + history: { + redo: 'Повторить', + undo: 'Отменить' + } + }, + tr: { + history: { + redo: 'Geri al', + undo: 'Yinele' + } + }, + zh_tw: { + history: { + redo: '重做', + undo: '復原' + } + }, + // jshint camelcase:true + }, + plugins: { + history: { + init: function (t) { + t.o.plugins.history = $.extend(true, { + _stack: [], + _index: -1, + _focusEl: undefined + }, t.o.plugins.history || {}); + + var btnBuildDefRedo = { + title: t.lang.history.redo, + ico: 'redo', + key: 'Y', + fn: function () { + if (t.o.plugins.history._index < t.o.plugins.history._stack.length - 1) { + t.o.plugins.history._index += 1; + var index = t.o.plugins.history._index; + var newState = t.o.plugins.history._stack[index]; + + t.execCmd('html', newState); + // because of some semantic optimisations we have to save the state back + // to history + t.o.plugins.history._stack[index] = t.$ed.html(); + + carretToEnd(); + toggleButtonStates(); + } + } + }; + + var btnBuildDefUndo = { + title: t.lang.history.undo, + ico: 'undo', + key: 'Z', + fn: function () { + if (t.o.plugins.history._index > 0) { + t.o.plugins.history._index -= 1; + var index = t.o.plugins.history._index, + newState = t.o.plugins.history._stack[index]; + + t.execCmd('html', newState); + // because of some semantic optimisations we have to save the state back + // to history + t.o.plugins.history._stack[index] = t.$ed.html(); + + carretToEnd(); + toggleButtonStates(); + } + } + }; + + var pushToHistory = function () { + var index = t.o.plugins.history._index, + stack = t.o.plugins.history._stack, + latestState = stack.slice(-1)[0] || '

', + prevState = stack[index], + newState = t.$ed.html(), + focusEl = t.doc.getSelection().focusNode, + focusElText = '', + latestStateTagsList, + newStateTagsList, + prevFocusEl = t.o.plugins.history._focusEl; + + latestStateTagsList = $('
' + latestState + '
').find('*').map(function () { + return this.localName; + }); + newStateTagsList = $('
' + newState + '
').find('*').map(function () { + return this.localName; + }); + if (focusEl) { + t.o.plugins.history._focusEl = focusEl; + focusElText = focusEl.outerHTML || focusEl.textContent; + } + + if (newState !== prevState) { + // a new stack entry is defined when current insert ends on a whitespace character + // or count of node elements has been changed + // or focused element differs from previous one + if (focusElText.slice(-1).match(/\s/) || + !arraysAreIdentical(latestStateTagsList, newStateTagsList) || + t.o.plugins.history._index <= 0 || focusEl !== prevFocusEl) + { + t.o.plugins.history._index += 1; + // remove newer entries in history when something new was added + // because timeline was changes with interaction + t.o.plugins.history._stack = stack.slice( + 0, t.o.plugins.history._index + ); + // now add new state to modified history + t.o.plugins.history._stack.push(newState); + } else { + // modify last stack entry + t.o.plugins.history._stack[index] = newState; + } + + toggleButtonStates(); + } + }; + + var toggleButtonStates = function () { + var index = t.o.plugins.history._index, + stackSize = t.o.plugins.history._stack.length, + undoState = (index > 0), + redoState = (stackSize !== 0 && index !== stackSize - 1); + + toggleButtonState('historyUndo', undoState); + toggleButtonState('historyRedo', redoState); + }; + + var toggleButtonState = function (btn, enable) { + var button = t.$box.find('.trumbowyg-' + btn + '-button'); + + if (enable) { + button.removeClass('trumbowyg-disable'); + } else if (!button.hasClass('trumbowyg-disable')) { + button.addClass('trumbowyg-disable'); + } + }; + + var arraysAreIdentical = function (a, b) { + if (a === b) { + return true; + } + if (a == null || b == null) { + return false; + } + if (a.length !== b.length) { + return false; + } + + for (var i = 0; i < a.length; i += 1) { + if (a[i] !== b[i]) { + return false; + } + } + return true; + }; + + var carretToEnd = function () { + var node = t.doc.getSelection().focusNode, + range = t.doc.createRange(); + + if (node.childNodes.length > 0) { + range.setStartAfter(node.childNodes[node.childNodes.length - 1]); + range.setEndAfter(node.childNodes[node.childNodes.length - 1]); + t.doc.getSelection().removeAllRanges(); + t.doc.getSelection().addRange(range); + } + }; + + t.$c.on('tbwinit tbwchange', pushToHistory); + + t.addBtnDef('historyRedo', btnBuildDefRedo); + t.addBtnDef('historyUndo', btnBuildDefUndo); + } + } + } + }); +})(jQuery); diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/history/trumbowyg.history.min.js b/vasl_templates/webapp/static/trumbowyg/plugins/history/trumbowyg.history.min.js new file mode 100644 index 0000000..4532679 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/history/trumbowyg.history.min.js @@ -0,0 +1,8 @@ +/*/* =========================================================== + * trumbowyg.history.js v1.0 + * history plugin for Trumbowyg + * http://alex-d.github.com/Trumbowyg + * =========================================================== + * Author : Sven Dunemann [dunemann@forelabs.eu] + */ +!function(o){"use strict";o.extend(!0,o.trumbowyg,{langs:{en:{history:{redo:"Redo",undo:"Undo"}},by:{history:{redo:"Паўтарыць",undo:"Скасаваць"}},da:{history:{redo:"Annuller fortryd",undo:"Fortryd"}},de:{history:{redo:"Wiederholen",undo:"Rückgängig"}},et:{history:{redo:"Võta tagasi",undo:"Tee uuesti"}},fr:{history:{redo:"Annuler",undo:"Rétablir"}},hu:{history:{redo:"Visszállít",undo:"Visszavon"}},ko:{history:{redo:"다시 실행",undo:"되돌리기"}},pt_br:{history:{redo:"Refazer",undo:"Desfazer"}},ru:{history:{redo:"Повторить",undo:"Отменить"}},tr:{history:{redo:"Geri al",undo:"Yinele"}},zh_tw:{history:{redo:"重做",undo:"復原"}}},plugins:{history:{init:function(i){i.o.plugins.history=o.extend(!0,{_stack:[],_index:-1,_focusEl:void 0},i.o.plugins.history||{});var t={title:i.lang.history.redo,ico:"redo",key:"Y",fn:function(){if(i.o.plugins.history._index0){i.o.plugins.history._index-=1;var o=i.o.plugins.history._index,t=i.o.plugins.history._stack[o];i.execCmd("html",t),i.o.plugins.history._stack[o]=i.$ed.html(),d(),e()}}},e=function(){var o=i.o.plugins.history._index,t=i.o.plugins.history._stack.length,n=0!==t&&o!==t-1;s("historyUndo",o>0),s("historyRedo",n)},s=function(o,t){var n=i.$box.find(".trumbowyg-"+o+"-button");t?n.removeClass("trumbowyg-disable"):n.hasClass("trumbowyg-disable")||n.addClass("trumbowyg-disable")},r=function(o,i){if(o===i)return!0;if(null==o||null==i)return!1;if(o.length!==i.length)return!1;for(var t=0;t0&&(t.setStartAfter(o.childNodes[o.childNodes.length-1]),t.setEndAfter(o.childNodes[o.childNodes.length-1]),i.doc.getSelection().removeAllRanges(),i.doc.getSelection().addRange(t))};i.$c.on("tbwinit tbwchange",(function(){var t,n,s=i.o.plugins.history._index,d=i.o.plugins.history._stack,l=d.slice(-1)[0]||"

",u=d[s],h=i.$ed.html(),c=i.doc.getSelection().focusNode,a="",y=i.o.plugins.history._focusEl;t=o("
"+l+"
").find("*").map((function(){return this.localName})),n=o("
"+h+"
").find("*").map((function(){return this.localName})),c&&(i.o.plugins.history._focusEl=c,a=c.outerHTML||c.textContent),h!==u&&(a.slice(-1).match(/\s/)||!r(t,n)||i.o.plugins.history._index<=0||c!==y?(i.o.plugins.history._index+=1,i.o.plugins.history._stack=d.slice(0,i.o.plugins.history._index),i.o.plugins.history._stack.push(h)):i.o.plugins.history._stack[s]=h,e())})),i.addBtnDef("historyRedo",t),i.addBtnDef("historyUndo",n)}}}})}(jQuery); \ No newline at end of file diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/indent/trumbowyg.indent.js b/vasl_templates/webapp/static/trumbowyg/plugins/indent/trumbowyg.indent.js new file mode 100644 index 0000000..4d0a388 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/indent/trumbowyg.indent.js @@ -0,0 +1,78 @@ + +/* =========================================================== + * trumbowyg.indent.js v1.0 + * Indent or Outdent plugin for Trumbowyg + * http://alex-d.github.com/Trumbowyg + * =========================================================== + * Author : Fabacks + * Website : https://github.com/Fabacks + */ + + (function ($) { + 'use strict'; + + $.extend(true, $.trumbowyg, { + langs: { + // jshint camelcase:false + en: { + indent: 'Indent', + outdent: 'Outdent' + }, + by: { + indent: 'Водступ', + outdent: 'Выступ' + }, + et: { + indent: 'Taande suurendamine', + outdent: 'Taande vähendamine' + }, + fr: { + indent: 'Augmenter le retrait', + outdent: 'Diminuer le retrait' + }, + pt_br: { + indent: 'Aumentar Recuo', + outdent: 'Diminuir Recuo' + }, + ru: { + indent: 'Отступ', + outdent: 'Выступ' + }, + tr: { + indent: 'Girinti', + outdent: 'Çıkıntı' + }, + // jshint camelcase:true + } + }); + + // Adds the extra button definition + $.extend(true, $.trumbowyg, { + plugins: { + paragraph: { + init: function (trumbowyg) { + var indentBtnDef = { + fn: 'indent', + title: trumbowyg.lang.indent, + isSupported: function () { + return !!document.queryCommandSupported && !!document.queryCommandSupported('indent'); + }, + ico: 'indent' + }; + + var outdentBtnDef = { + fn: 'outdent', + title: trumbowyg.lang.outdent, + isSupported: function () { + return !!document.queryCommandSupported && !!document.queryCommandSupported('outdent'); + }, + ico: 'outdent' + }; + + trumbowyg.addBtnDef('indent', indentBtnDef); + trumbowyg.addBtnDef('outdent', outdentBtnDef); + } + } + } + }); +})(jQuery); diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/indent/trumbowyg.indent.min.js b/vasl_templates/webapp/static/trumbowyg/plugins/indent/trumbowyg.indent.min.js new file mode 100644 index 0000000..f956321 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/indent/trumbowyg.indent.min.js @@ -0,0 +1,9 @@ +/* =========================================================== + * trumbowyg.indent.js v1.0 + * Indent or Outdent plugin for Trumbowyg + * http://alex-d.github.com/Trumbowyg + * =========================================================== + * Author : Fabacks + * Website : https://github.com/Fabacks + */ +!function(n){"use strict";n.extend(!0,n.trumbowyg,{langs:{en:{indent:"Indent",outdent:"Outdent"},by:{indent:"Водступ",outdent:"Выступ"},et:{indent:"Taande suurendamine",outdent:"Taande vähendamine"},fr:{indent:"Augmenter le retrait",outdent:"Diminuer le retrait"},pt_br:{indent:"Aumentar Recuo",outdent:"Diminuir Recuo"},ru:{indent:"Отступ",outdent:"Выступ"},tr:{indent:"Girinti",outdent:"Çıkıntı"}}}),n.extend(!0,n.trumbowyg,{plugins:{paragraph:{init:function(n){var t={fn:"indent",title:n.lang.indent,isSupported:function(){return!!document.queryCommandSupported&&!!document.queryCommandSupported("indent")},ico:"indent"},e={fn:"outdent",title:n.lang.outdent,isSupported:function(){return!!document.queryCommandSupported&&!!document.queryCommandSupported("outdent")},ico:"outdent"};n.addBtnDef("indent",t),n.addBtnDef("outdent",e)}}}})}(jQuery); \ No newline at end of file diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/insertaudio/trumbowyg.insertaudio.js b/vasl_templates/webapp/static/trumbowyg/plugins/insertaudio/trumbowyg.insertaudio.js new file mode 100644 index 0000000..ed721f3 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/insertaudio/trumbowyg.insertaudio.js @@ -0,0 +1,109 @@ +/*/* =========================================================== + * trumbowyg.insertaudio.js v1.0 + * InsertAudio plugin for Trumbowyg + * http://alex-d.github.com/Trumbowyg + * =========================================================== + * Author : Adam Hess (AdamHess) + */ + +(function ($) { + 'use strict'; + + var insertAudioOptions = { + src: { + label: 'URL', + required: true + }, + autoplay: { + label: 'AutoPlay', + required: false, + type: 'checkbox' + }, + muted: { + label: 'Muted', + required: false, + type: 'checkbox' + }, + preload: { + label: 'preload options', + required: false + } + }; + + + $.extend(true, $.trumbowyg, { + langs: { + // jshint camelcase:false + en: { + insertAudio: 'Insert Audio' + }, + by: { + insertAudio: 'Уставіць аўдыё' + }, + da: { + insertAudio: 'Indsæt lyd' + }, + et: { + insertAudio: 'Lisa helifail' + }, + fr: { + insertAudio: 'Insérer un son' + }, + hu: { + insertAudio: 'Audio beszúrás' + }, + ja: { + insertAudio: '音声の挿入' + }, + ko: { + insertAudio: '소리 넣기' + }, + pt_br: { + insertAudio: 'Inserir áudio' + }, + ru: { + insertAudio: 'Вставить аудио' + }, + tr: { + insertAudio: 'Ses Ekle' + }, + // jshint camelcase:true + }, + plugins: { + insertAudio: { + init: function (trumbowyg) { + var btnDef = { + fn: function () { + var insertAudioCallback = function (v) { + // controls should always be show otherwise the audio will + // be invisible defeating the point of a wysiwyg + var html = '")[0];return i.range.deleteContents(),i.range.insertNode(n),!0}))}};i.addBtnDef("insertAudio",t)}}}})}(jQuery); \ No newline at end of file diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/lineheight/trumbowyg.lineheight.js b/vasl_templates/webapp/static/trumbowyg/plugins/lineheight/trumbowyg.lineheight.js new file mode 100644 index 0000000..366699f --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/lineheight/trumbowyg.lineheight.js @@ -0,0 +1,198 @@ +(function ($) { + 'use strict'; + + $.extend(true, $.trumbowyg, { + langs: { + // jshint camelcase:false + en: { + lineheight: 'Line height', + lineheights: { + '0.9': 'Small', + 'normal': 'Regular', + '1.5': 'Large', + '2.0': 'Extra large' + } + }, + by: { + lineheight: 'Міжрадковы інтэрвал', + lineheights: { + '0.9': 'Маленькі', + 'normal': 'Звычайны', + '1.5': 'Вялікі', + '2.0': 'Вельмі вялікі' + } + }, + da: { + lineheight: 'Linjehøjde', + lineheights: { + '0.9': 'Lille', + 'normal': 'Normal', + '1.5': 'Stor', + '2.0': 'Ekstra stor' + } + }, + et: { + lineheight: 'Reavahe', + lineheights: { + '0.9': 'Väike', + 'normal': 'Tavaline', + '1.5': 'Suur', + '2.0': 'Väga suur' + } + }, + fr: { + lineheight: 'Hauteur de ligne', + lineheights: { + '0.9': 'Petite', + 'normal': 'Normale', + '1.5': 'Grande', + '2.0': 'Très grande' + } + }, + hu: { + lineheight: 'Line height', + lineheights: { + '0.9': 'Small', + 'normal': 'Regular', + '1.5': 'Large', + '2.0': 'Extra large' + } + }, + it: { + lineheight: 'Altezza linea', + lineheights: { + '0.9': 'Bassa', + 'normal': 'Normale', + '1.5': 'Alta', + '2.0': 'Molto alta' + } + }, + ko: { + lineheight: '줄 간격', + lineheights: { + '0.9': '좁게', + 'normal': '보통', + '1.5': '넓게', + '2.0': '아주 넓게' + } + }, + nl: { + lineheight: 'Regelhoogte', + lineheights: { + '0.9': 'Klein', + 'normal': 'Normaal', + '1.5': 'Groot', + '2.0': 'Extra groot' + } + }, + pt_br: { + lineheight: 'Altura de linha', + lineheights: { + '0.9': 'Pequena', + 'normal': 'Regular', + '1.5': 'Grande', + '2.0': 'Extra grande' + } + }, + ru: { + lineheight: 'Межстрочный интервал', + lineheights: { + '0.9': 'Маленький', + 'normal': 'Обычный', + '1.5': 'Большой', + '2.0': 'Очень большой' + } + }, + tr: { + lineheight: 'Satır yüksekliği', + lineheights: { + '0.9': 'Küçük', + 'normal': 'Normal', + '1.5': 'Büyük', + '2.0': 'Çok Büyük' + } + }, + zh_tw: { + lineheight: '文字間距', + lineheights: { + '0.9': '小', + 'normal': '正常', + '1.5': '大', + '2.0': '特大' + } + }, + } + }); + // jshint camelcase:true + + var defaultOptions = { + sizeList: [ + '0.9', + 'normal', + '1.5', + '2.0' + ] + }; + + // Add dropdown with font sizes + $.extend(true, $.trumbowyg, { + plugins: { + lineheight: { + init: function (trumbowyg) { + trumbowyg.o.plugins.lineheight = $.extend({}, + defaultOptions, + trumbowyg.o.plugins.lineheight || {} + ); + + trumbowyg.addBtnDef('lineheight', { + dropdown: buildDropdown(trumbowyg) + }); + } + } + } + }); + + // Build the dropdown + function buildDropdown(trumbowyg) { + var dropdown = []; + + $.each(trumbowyg.o.plugins.lineheight.sizeList, function(index, size) { + trumbowyg.addBtnDef('lineheight_' + size, { + text: trumbowyg.lang.lineheights[size] || size, + hasIcon: false, + fn: function(){ + trumbowyg.saveRange(); + var text = trumbowyg.getRangeText(); + if (text.replace(/\s/g, '') !== '') { + try { + var parent = getSelectionParentElement(); + $(parent).css('lineHeight', size); + } catch (e) { + } + } + } + }); + dropdown.push('lineheight_' + size); + }); + + return dropdown; + } + + // Get the selection's parent + function getSelectionParentElement() { + var parentEl = null, + selection; + if (window.getSelection) { + selection = window.getSelection(); + if (selection.rangeCount) { + parentEl = selection.getRangeAt(0).commonAncestorContainer; + if (parentEl.nodeType !== 1) { + parentEl = parentEl.parentNode; + } + } + } else if ((selection = document.selection) && selection.type !== 'Control') { + parentEl = selection.createRange().parentElement(); + } + return parentEl; + } +})(jQuery); diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/lineheight/trumbowyg.lineheight.min.js b/vasl_templates/webapp/static/trumbowyg/plugins/lineheight/trumbowyg.lineheight.min.js new file mode 100644 index 0000000..e014e71 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/lineheight/trumbowyg.lineheight.min.js @@ -0,0 +1 @@ +!function(e){"use strict";e.extend(!0,e.trumbowyg,{langs:{en:{lineheight:"Line height",lineheights:{.9:"Small",normal:"Regular",1.5:"Large","2.0":"Extra large"}},by:{lineheight:"Міжрадковы інтэрвал",lineheights:{.9:"Маленькі",normal:"Звычайны",1.5:"Вялікі","2.0":"Вельмі вялікі"}},da:{lineheight:"Linjehøjde",lineheights:{.9:"Lille",normal:"Normal",1.5:"Stor","2.0":"Ekstra stor"}},et:{lineheight:"Reavahe",lineheights:{.9:"Väike",normal:"Tavaline",1.5:"Suur","2.0":"Väga suur"}},fr:{lineheight:"Hauteur de ligne",lineheights:{.9:"Petite",normal:"Normale",1.5:"Grande","2.0":"Très grande"}},hu:{lineheight:"Line height",lineheights:{.9:"Small",normal:"Regular",1.5:"Large","2.0":"Extra large"}},it:{lineheight:"Altezza linea",lineheights:{.9:"Bassa",normal:"Normale",1.5:"Alta","2.0":"Molto alta"}},ko:{lineheight:"줄 간격",lineheights:{.9:"좁게",normal:"보통",1.5:"넓게","2.0":"아주 넓게"}},nl:{lineheight:"Regelhoogte",lineheights:{.9:"Klein",normal:"Normaal",1.5:"Groot","2.0":"Extra groot"}},pt_br:{lineheight:"Altura de linha",lineheights:{.9:"Pequena",normal:"Regular",1.5:"Grande","2.0":"Extra grande"}},ru:{lineheight:"Межстрочный интервал",lineheights:{.9:"Маленький",normal:"Обычный",1.5:"Большой","2.0":"Очень большой"}},tr:{lineheight:"Satır yüksekliği",lineheights:{.9:"Küçük",normal:"Normal",1.5:"Büyük","2.0":"Çok Büyük"}},zh_tw:{lineheight:"文字間距",lineheights:{.9:"小",normal:"正常",1.5:"大","2.0":"特大"}}}});var n={sizeList:["0.9","normal","1.5","2.0"]};function i(n){var i=[];return e.each(n.o.plugins.lineheight.sizeList,(function(t,l){n.addBtnDef("lineheight_"+l,{text:n.lang.lineheights[l]||l,hasIcon:!1,fn:function(){if(n.saveRange(),""!==n.getRangeText().replace(/\s/g,""))try{var i=function(){var e,n=null;window.getSelection?(e=window.getSelection()).rangeCount&&1!==(n=e.getRangeAt(0).commonAncestorContainer).nodeType&&(n=n.parentNode):(e=document.selection)&&"Control"!==e.type&&(n=e.createRange().parentElement());return n}();e(i).css("lineHeight",l)}catch(e){}}}),i.push("lineheight_"+l)})),i}e.extend(!0,e.trumbowyg,{plugins:{lineheight:{init:function(t){t.o.plugins.lineheight=e.extend({},n,t.o.plugins.lineheight||{}),t.addBtnDef("lineheight",{dropdown:i(t)})}}}})}(jQuery); \ No newline at end of file diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/mathml/trumbowyg.mathml.js b/vasl_templates/webapp/static/trumbowyg/plugins/mathml/trumbowyg.mathml.js new file mode 100644 index 0000000..bd60e27 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/mathml/trumbowyg.mathml.js @@ -0,0 +1,149 @@ +/* =========================================================== + * trumbowyg.mathMl.js v1.0 + * MathML plugin for Trumbowyg + * http://alex-d.github.com/Trumbowyg + * =========================================================== + * Author : loclamor + */ + +/* globals MathJax */ +(function ($) { + 'use strict'; + $.extend(true, $.trumbowyg, { + langs: { + // jshint camelcase:false + en: { + mathml: 'Insert Formulas', + formulas: 'Formulas', + inline: 'Inline' + }, + by: { + mathml: 'Уставіць формулу', + formulas: 'Формула', + inline: 'Inline-элемент' + }, + da: { + mathml: 'Indsæt formler', + formulas: 'Formler', + inline: 'Inline' + }, + et: { + mathml: 'Sisesta valem', + formulas: 'Valemid', + inline: 'Teksti sees' + }, + fr: { + mathml: 'Inserer une formule', + formulas: 'Formule', + inline: 'En ligne' + }, + hu: { + mathml: 'Formulák beszúrás', + formulas: 'Formulák', + inline: 'Inline' + }, + ko: { + mathml: '수식 넣기', + formulas: '수식', + inline: '글 안에 넣기' + }, + pt_br: { + mathml: 'Inserir fórmulas', + formulas: 'Fórmulas', + inline: 'Em linha' + }, + ru: { + mathml: 'Вставить формулу', + formulas: 'Формула', + inline: 'Строчный элемент' + }, + tr: { + mathml: 'Formül Ekle', + formulas: 'Formüller', + inline: 'Satır içi' + }, + zh_tw: { + mathml: '插入方程式', + formulas: '方程式', + inline: '內嵌' + }, + }, + // jshint camelcase:true + + plugins: { + mathml: { + init: function (trumbowyg) { + var mathMlOptions = { + formulas: { + label: trumbowyg.lang.formulas, + required: true, + value: '' + }, + inline: { + label: trumbowyg.lang.inline, + attributes: { + checked: true + }, + type: 'checkbox', + required: false, + } + }; + + var mathmlCallback = function (v) { + var delimiter = v.inline ? '$' : '$$'; + if (trumbowyg.currentMathNode) { + $(trumbowyg.currentMathNode) + .html(delimiter + ' ' + v.formulas + ' ' + delimiter) + .attr('formulas', v.formulas) + .attr('inline', (v.inline ? 'true' : 'false')); + } else { + var html = '' + delimiter + ' ' + v.formulas + ' ' + delimiter + ''; + var node = $(html)[0]; + node.onclick = openModal; + + trumbowyg.range.deleteContents(); + trumbowyg.range.insertNode(node); + } + + trumbowyg.currentMathNode = false; + MathJax.Hub.Queue(['Typeset', MathJax.Hub]); + return true; + }; + + var openModal = function () { + trumbowyg.currentMathNode = this; + mathMlOptions.formulas.value = $(this).attr('formulas'); + + if ($(this).attr('inline') === 'true') { + mathMlOptions.inline.attributes.checked = true; + } else { + delete mathMlOptions.inline.attributes.checked; + } + + trumbowyg.openModalInsert(trumbowyg.lang.mathml, mathMlOptions, mathmlCallback); + }; + + var btnDef = { + fn: function () { + trumbowyg.saveRange(); + + mathMlOptions.formulas.value = trumbowyg.getRangeText(); + mathMlOptions.inline.attributes.checked = true; + trumbowyg.openModalInsert(trumbowyg.lang.mathml, mathMlOptions, mathmlCallback); + } + }; + + trumbowyg.$ta.on('tbwinit', function () { + var nodes = trumbowyg.$ed.find('[formulas]'); + + nodes.each(function (i, elem) { + elem.onclick = openModal; + }); + }); + + trumbowyg.addBtnDef('mathml', btnDef); + } + } + } + }); +})(jQuery); diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/mathml/trumbowyg.mathml.min.js b/vasl_templates/webapp/static/trumbowyg/plugins/mathml/trumbowyg.mathml.min.js new file mode 100644 index 0000000..d655106 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/mathml/trumbowyg.mathml.min.js @@ -0,0 +1,8 @@ +/* =========================================================== + * trumbowyg.mathMl.js v1.0 + * MathML plugin for Trumbowyg + * http://alex-d.github.com/Trumbowyg + * =========================================================== + * Author : loclamor + */ +!function(e){"use strict";e.extend(!0,e.trumbowyg,{langs:{en:{mathml:"Insert Formulas",formulas:"Formulas",inline:"Inline"},by:{mathml:"Уставіць формулу",formulas:"Формула",inline:"Inline-элемент"},da:{mathml:"Indsæt formler",formulas:"Formler",inline:"Inline"},et:{mathml:"Sisesta valem",formulas:"Valemid",inline:"Teksti sees"},fr:{mathml:"Inserer une formule",formulas:"Formule",inline:"En ligne"},hu:{mathml:"Formulák beszúrás",formulas:"Formulák",inline:"Inline"},ko:{mathml:"수식 넣기",formulas:"수식",inline:"글 안에 넣기"},pt_br:{mathml:"Inserir fórmulas",formulas:"Fórmulas",inline:"Em linha"},ru:{mathml:"Вставить формулу",formulas:"Формула",inline:"Строчный элемент"},tr:{mathml:"Formül Ekle",formulas:"Formüller",inline:"Satır içi"},zh_tw:{mathml:"插入方程式",formulas:"方程式",inline:"內嵌"}},plugins:{mathml:{init:function(n){var l={formulas:{label:n.lang.formulas,required:!0,value:""},inline:{label:n.lang.inline,attributes:{checked:!0},type:"checkbox",required:!1}},a=function(l){var a=l.inline?"$":"$$";if(n.currentMathNode)e(n.currentMathNode).html(a+" "+l.formulas+" "+a).attr("formulas",l.formulas).attr("inline",l.inline?"true":"false");else{var r=''+a+" "+l.formulas+" "+a+"",i=e(r)[0];i.onclick=t,n.range.deleteContents(),n.range.insertNode(i)}return n.currentMathNode=!1,MathJax.Hub.Queue(["Typeset",MathJax.Hub]),!0},t=function(){n.currentMathNode=this,l.formulas.value=e(this).attr("formulas"),"true"===e(this).attr("inline")?l.inline.attributes.checked=!0:delete l.inline.attributes.checked,n.openModalInsert(n.lang.mathml,l,a)},r={fn:function(){n.saveRange(),l.formulas.value=n.getRangeText(),l.inline.attributes.checked=!0,n.openModalInsert(n.lang.mathml,l,a)}};n.$ta.on("tbwinit",(function(){n.$ed.find("[formulas]").each((function(e,n){n.onclick=t}))})),n.addBtnDef("mathml",r)}}}})}(jQuery); \ No newline at end of file diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/mathml/ui/sass/trumbowyg.mathml.scss b/vasl_templates/webapp/static/trumbowyg/plugins/mathml/ui/sass/trumbowyg.mathml.scss new file mode 100644 index 0000000..8141027 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/mathml/ui/sass/trumbowyg.mathml.scss @@ -0,0 +1,41 @@ +/** + * Trumbowyg v2.25.2 - A lightweight WYSIWYG editor + * Default stylesheet for Trumbowyg editor plugin + * ------------------------ + * @link http://alex-d.github.io/Trumbowyg + * @license MIT + * @author Alexandre Demode (Alex-D) + * Twitter : @AlexandreDemode + * Website : alex-d.fr + */ + +[formulas] { + position: relative; + display: inline-block; + pointer-events: none; + + &[inline="false"] { + display: block; + width: 100%; + } + + &::after { + content: '\270E'; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + opacity: 0; + background-color: rgba(255, 255, 255, 0.83); + box-shadow: 0 0 5px 5px rgba(255, 255, 255, 0.83); + cursor: pointer; + pointer-events: auto; + } + + &:hover { + &::after { + opacity: 1; + } + } +} diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/mathml/ui/trumbowyg.mathml.css b/vasl_templates/webapp/static/trumbowyg/plugins/mathml/ui/trumbowyg.mathml.css new file mode 100644 index 0000000..9fd3e45 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/mathml/ui/trumbowyg.mathml.css @@ -0,0 +1,33 @@ +/** + * Trumbowyg v2.25.2 - A lightweight WYSIWYG editor + * Trumbowyg plugin stylesheet + * ------------------------ + * @link http://alex-d.github.io/Trumbowyg + * @license MIT + * @author Alexandre Demode (Alex-D) + * Twitter : @AlexandreDemode + * Website : alex-d.fr + */ + +[formulas] { + position: relative; + display: inline-block; + pointer-events: none; } + [formulas][inline="false"] { + display: block; + width: 100%; } + [formulas]::after { + content: '\270E'; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + opacity: 0; + background-color: rgba(255, 255, 255, 0.83); + -webkit-box-shadow: 0 0 5px 5px rgba(255, 255, 255, 0.83); + box-shadow: 0 0 5px 5px rgba(255, 255, 255, 0.83); + cursor: pointer; + pointer-events: auto; } + [formulas]:hover::after { + opacity: 1; } diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/mathml/ui/trumbowyg.mathml.min.css b/vasl_templates/webapp/static/trumbowyg/plugins/mathml/ui/trumbowyg.mathml.min.css new file mode 100644 index 0000000..2ee7a4f --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/mathml/ui/trumbowyg.mathml.min.css @@ -0,0 +1,2 @@ +/** Trumbowyg v2.25.2 - A lightweight WYSIWYG editor - alex-d.github.io/Trumbowyg - License MIT - Author : Alexandre Demode (Alex-D) / alex-d.fr */ +[formulas]{position:relative;display:inline-block;pointer-events:none}[formulas][inline=false]{display:block;width:100%}[formulas]::after{content:'\270E';position:absolute;top:0;right:0;bottom:0;left:0;opacity:0;background-color:rgba(255,255,255,.83);-webkit-box-shadow:0 0 5px 5px rgba(255,255,255,.83);box-shadow:0 0 5px 5px rgba(255,255,255,.83);cursor:pointer;pointer-events:auto}[formulas]:hover::after{opacity:1} \ No newline at end of file diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/mention/trumbowyg.mention.js b/vasl_templates/webapp/static/trumbowyg/plugins/mention/trumbowyg.mention.js new file mode 100644 index 0000000..2a75f05 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/mention/trumbowyg.mention.js @@ -0,0 +1,125 @@ +/* =========================================================== + * trumbowyg.mention.js v0.1 + * Mention plugin for Trumbowyg + * http://alex-d.github.com/Trumbowyg + * =========================================================== + * Author : Viper + * Github: https://github.com/Globulopolis + * Website: http://киноархив.com + */ + +(function ($) { + 'use strict'; + + var defaultOptions = { + source: [], + formatDropdownItem: formatDropdownItem, + formatResult: formatResult + }; + + $.extend(true, $.trumbowyg, { + langs: { + // jshint camelcase:false + en: { + mention: 'Mention' + }, + by: { + mention: 'Згадаць' + }, + da: { + mention: 'Nævn' + }, + et: { + mention: 'Maini' + }, + fr: { + mention: 'Mentionner' + }, + hu: { + mention: 'Említ' + }, + ko: { + mention: '언급' + }, + pt_br: { + mention: 'Menção' + }, + ru: { + mention: 'Упомянуть' + }, + tr: { + mention: 'Bahset' + }, + zh_tw: { + mention: '標記' + }, + // jshint camelcase:true + }, + + plugins: { + mention: { + init: function (trumbowyg) { + trumbowyg.o.plugins.mention = $.extend(true, {}, defaultOptions, trumbowyg.o.plugins.mention || {}); + + var btnDef = { + dropdown: buildDropdown(trumbowyg.o.plugins.mention.source, trumbowyg) + }; + + trumbowyg.addBtnDef('mention', btnDef); + } + } + } + }); + + /** + * Build dropdown list + * + * @param {Array} items Items + * @param {object} trumbowyg Editor + * + * @return {Array} + */ + function buildDropdown(items, trumbowyg) { + var dropdown = []; + + $.each(items, function (i, item) { + var btn = 'mention-' + i, + btnDef = { + hasIcon: false, + text: trumbowyg.o.plugins.mention.formatDropdownItem(item), + fn: function () { + trumbowyg.execCmd('insertHTML', trumbowyg.o.plugins.mention.formatResult(item)); + + return true; + } + }; + + trumbowyg.addBtnDef(btn, btnDef); + dropdown.push(btn); + }); + + return dropdown; + } + + /** + * Format item in dropdown. + * + * @param {object} item Item object. + * + * @return {string} + */ + function formatDropdownItem(item) { + return item.login; + } + + /** + * Format result pasted in editor. + * + * @param {object} item Item object. + * + * @return {string} + */ + function formatResult(item) { + return '@' + item.login + ' '; + } +})(jQuery); diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/mention/trumbowyg.mention.min.js b/vasl_templates/webapp/static/trumbowyg/plugins/mention/trumbowyg.mention.min.js new file mode 100644 index 0000000..1583aba --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/mention/trumbowyg.mention.min.js @@ -0,0 +1,10 @@ +/* =========================================================== + * trumbowyg.mention.js v0.1 + * Mention plugin for Trumbowyg + * http://alex-d.github.com/Trumbowyg + * =========================================================== + * Author : Viper + * Github: https://github.com/Globulopolis + * Website: http://киноархив.com + */ +!function(n){"use strict";var t={source:[],formatDropdownItem:function(n){return n.login},formatResult:function(n){return"@"+n.login+" "}};function o(t,o){var e=[];return n.each(t,(function(n,t){var i="mention-"+n,r={hasIcon:!1,text:o.o.plugins.mention.formatDropdownItem(t),fn:function(){return o.execCmd("insertHTML",o.o.plugins.mention.formatResult(t)),!0}};o.addBtnDef(i,r),e.push(i)})),e}n.extend(!0,n.trumbowyg,{langs:{en:{mention:"Mention"},by:{mention:"Згадаць"},da:{mention:"Nævn"},et:{mention:"Maini"},fr:{mention:"Mentionner"},hu:{mention:"Említ"},ko:{mention:"언급"},pt_br:{mention:"Menção"},ru:{mention:"Упомянуть"},tr:{mention:"Bahset"},zh_tw:{mention:"標記"}},plugins:{mention:{init:function(e){e.o.plugins.mention=n.extend(!0,{},t,e.o.plugins.mention||{});var i={dropdown:o(e.o.plugins.mention.source,e)};e.addBtnDef("mention",i)}}}})}(jQuery); \ No newline at end of file diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/mention/ui/sass/trumbowyg.mention.scss b/vasl_templates/webapp/static/trumbowyg/plugins/mention/ui/sass/trumbowyg.mention.scss new file mode 100644 index 0000000..71acc1a --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/mention/ui/sass/trumbowyg.mention.scss @@ -0,0 +1,29 @@ +/** + * Trumbowyg v2.25.2 - A lightweight WYSIWYG editor + * Default stylesheet for Trumbowyg editor plugin + * ------------------------ + * @link http://alex-d.github.io/Trumbowyg + * @license MIT + * @author Alexandre Demode (Alex-D) + * Twitter : @AlexandreDemode + * Website : alex-d.fr + */ + +.trumbowyg-dropdown-mention { + button { + position: relative; + white-space: nowrap; + + &:after { + content: ""; + position: absolute; + top: 0; + right: 0; + width: 15%; + height: 100%; + background-size: 100%; + background-image: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, #ffffff 80%, #ffffff 100%); + pointer-events: none; + } + } +} diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/mention/ui/trumbowyg.mention.css b/vasl_templates/webapp/static/trumbowyg/plugins/mention/ui/trumbowyg.mention.css new file mode 100644 index 0000000..332a606 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/mention/ui/trumbowyg.mention.css @@ -0,0 +1,28 @@ +/** + * Trumbowyg v2.25.2 - A lightweight WYSIWYG editor + * Trumbowyg plugin stylesheet + * ------------------------ + * @link http://alex-d.github.io/Trumbowyg + * @license MIT + * @author Alexandre Demode (Alex-D) + * Twitter : @AlexandreDemode + * Website : alex-d.fr + */ + +.trumbowyg-dropdown-mention button { + position: relative; + white-space: nowrap; } + .trumbowyg-dropdown-mention button:after { + content: ""; + position: absolute; + top: 0; + right: 0; + width: 15%; + height: 100%; + -webkit-background-size: 100% 100%; + background-size: 100%; + background-image: -webkit-gradient(linear, left top, right top, from(rgba(255, 255, 255, 0)), color-stop(80%, #ffffff), to(#ffffff)); + background-image: -webkit-linear-gradient(left, rgba(255, 255, 255, 0) 0%, #ffffff 80%, #ffffff 100%); + background-image: -o-linear-gradient(left, rgba(255, 255, 255, 0) 0%, #ffffff 80%, #ffffff 100%); + background-image: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, #ffffff 80%, #ffffff 100%); + pointer-events: none; } diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/mention/ui/trumbowyg.mention.min.css b/vasl_templates/webapp/static/trumbowyg/plugins/mention/ui/trumbowyg.mention.min.css new file mode 100644 index 0000000..df50d95 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/mention/ui/trumbowyg.mention.min.css @@ -0,0 +1,2 @@ +/** Trumbowyg v2.25.2 - A lightweight WYSIWYG editor - alex-d.github.io/Trumbowyg - License MIT - Author : Alexandre Demode (Alex-D) / alex-d.fr */ +.trumbowyg-dropdown-mention button{position:relative;white-space:nowrap}.trumbowyg-dropdown-mention button:after{content:"";position:absolute;top:0;right:0;width:15%;height:100%;-webkit-background-size:100% 100%;background-size:100%;background-image:-webkit-gradient(linear,left top,right top,from(rgba(255,255,255,0)),color-stop(80%,#fff),to(#fff));background-image:-webkit-linear-gradient(left,rgba(255,255,255,0) 0,#fff 80%,#fff 100%);background-image:-o-linear-gradient(left,rgba(255,255,255,0) 0,#fff 80%,#fff 100%);background-image:linear-gradient(to right,rgba(255,255,255,0) 0,#fff 80%,#fff 100%);pointer-events:none} \ No newline at end of file diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/noembed/trumbowyg.noembed.js b/vasl_templates/webapp/static/trumbowyg/plugins/noembed/trumbowyg.noembed.js new file mode 100644 index 0000000..2551905 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/noembed/trumbowyg.noembed.js @@ -0,0 +1,132 @@ +/* =========================================================== + * trumbowyg.noembed.js v1.0 + * noEmbed plugin for Trumbowyg + * http://alex-d.github.com/Trumbowyg + * =========================================================== + * Author : Jake Johns (jakejohns) + */ + +(function ($) { + 'use strict'; + + var defaultOptions = { + proxy: 'https://noembed.com/embed?nowrap=on', + urlFiled: 'url', + data: [], + success: undefined, + error: undefined + }; + + $.extend(true, $.trumbowyg, { + langs: { + // jshint camelcase:false + en: { + noembed: 'Noembed', + noembedError: 'Error' + }, + by: { + noembedError: 'Памылка' + }, + cs: { + noembedError: 'Chyba' + }, + da: { + noembedError: 'Fejl' + }, + et: { + noembed: 'Noembed', + noembedError: 'Viga' + }, + fr: { + noembedError: 'Erreur' + }, + hu: { + noembed: 'Noembed', + noembedError: 'Hiba' + }, + ja: { + noembedError: 'エラー' + }, + ko: { + noembed: 'oEmbed 넣기', + noembedError: '에러' + }, + pt_br: { + noembed: 'Incorporar', + noembedError: 'Erro' + }, + ru: { + noembedError: 'Ошибка' + }, + sk: { + noembedError: 'Chyba' + }, + tr: { + noembedError: 'Hata' + }, + zh_tw: { + noembed: '插入影片', + noembedError: '錯誤' + }, + // jshint camelcase:true + }, + + plugins: { + noembed: { + init: function (trumbowyg) { + trumbowyg.o.plugins.noembed = $.extend(true, {}, defaultOptions, trumbowyg.o.plugins.noembed || {}); + + var btnDef = { + fn: function () { + var $modal = trumbowyg.openModalInsert( + // Title + trumbowyg.lang.noembed, + + // Fields + { + url: { + label: 'URL', + required: true + } + }, + + // Callback + function (data) { + $.ajax({ + url: trumbowyg.o.plugins.noembed.proxy, + type: 'GET', + data: data, + cache: false, + dataType: 'json', + + success: trumbowyg.o.plugins.noembed.success || function (data) { + if (data.html) { + trumbowyg.execCmd('insertHTML', data.html); + setTimeout(function () { + trumbowyg.closeModal(); + }, 250); + } else { + trumbowyg.addErrorOnModalField( + $('input[type=text]', $modal), + data.error + ); + } + }, + error: trumbowyg.o.plugins.noembed.error || function () { + trumbowyg.addErrorOnModalField( + $('input[type=text]', $modal), + trumbowyg.lang.noembedError + ); + } + }); + } + ); + } + }; + + trumbowyg.addBtnDef('noembed', btnDef); + } + } + } + }); +})(jQuery); diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/noembed/trumbowyg.noembed.min.js b/vasl_templates/webapp/static/trumbowyg/plugins/noembed/trumbowyg.noembed.min.js new file mode 100644 index 0000000..37bc622 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/noembed/trumbowyg.noembed.min.js @@ -0,0 +1,8 @@ +/* =========================================================== + * trumbowyg.noembed.js v1.0 + * noEmbed plugin for Trumbowyg + * http://alex-d.github.com/Trumbowyg + * =========================================================== + * Author : Jake Johns (jakejohns) + */ +!function(e){"use strict";var r={proxy:"https://noembed.com/embed?nowrap=on",urlFiled:"url",data:[],success:void 0,error:void 0};e.extend(!0,e.trumbowyg,{langs:{en:{noembed:"Noembed",noembedError:"Error"},by:{noembedError:"Памылка"},cs:{noembedError:"Chyba"},da:{noembedError:"Fejl"},et:{noembed:"Noembed",noembedError:"Viga"},fr:{noembedError:"Erreur"},hu:{noembed:"Noembed",noembedError:"Hiba"},ja:{noembedError:"エラー"},ko:{noembed:"oEmbed 넣기",noembedError:"에러"},pt_br:{noembed:"Incorporar",noembedError:"Erro"},ru:{noembedError:"Ошибка"},sk:{noembedError:"Chyba"},tr:{noembedError:"Hata"},zh_tw:{noembed:"插入影片",noembedError:"錯誤"}},plugins:{noembed:{init:function(o){o.o.plugins.noembed=e.extend(!0,{},r,o.o.plugins.noembed||{});var n={fn:function(){var r=o.openModalInsert(o.lang.noembed,{url:{label:"URL",required:!0}},(function(n){e.ajax({url:o.o.plugins.noembed.proxy,type:"GET",data:n,cache:!1,dataType:"json",success:o.o.plugins.noembed.success||function(n){n.html?(o.execCmd("insertHTML",n.html),setTimeout((function(){o.closeModal()}),250)):o.addErrorOnModalField(e("input[type=text]",r),n.error)},error:o.o.plugins.noembed.error||function(){o.addErrorOnModalField(e("input[type=text]",r),o.lang.noembedError)}})}))}};o.addBtnDef("noembed",n)}}}})}(jQuery); \ No newline at end of file diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/pasteembed/trumbowyg.pasteembed.js b/vasl_templates/webapp/static/trumbowyg/plugins/pasteembed/trumbowyg.pasteembed.js new file mode 100644 index 0000000..b6c5e39 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/pasteembed/trumbowyg.pasteembed.js @@ -0,0 +1,96 @@ +/* =========================================================== + * trumbowyg.pasteembed.js v1.0 + * Url paste to iframe with noembed. Plugin for Trumbowyg + * http://alex-d.github.com/Trumbowyg + * =========================================================== + * Author : Max Seelig + * Facebook : https://facebook.com/maxse + * Website : https://www.maxmade.nl/ + */ + +(function($) { + 'use strict'; + + var defaultOptions = { + enabled: true, + endpoints: [ + 'https://noembed.com/embed?nowrap=on', + 'https://api.maxmade.nl/url2iframe/embed' + ] + }; + + $.extend(true, $.trumbowyg, { + plugins: { + pasteEmbed: { + init: function(trumbowyg) { + trumbowyg.o.plugins.pasteEmbed = $.extend(true, {}, defaultOptions, trumbowyg.o.plugins.pasteEmbed || {}); + + if (!trumbowyg.o.plugins.pasteEmbed.enabled) { + return; + } + + trumbowyg.pasteHandlers.push(function(pasteEvent) { + try { + var clipboardData = (pasteEvent.originalEvent || pasteEvent).clipboardData, + pastedData = clipboardData.getData('Text'), + endpoints = trumbowyg.o.plugins.pasteEmbed.endpoints, + request = null; + + if (pastedData.startsWith('http')) { + pasteEvent.stopPropagation(); + pasteEvent.preventDefault(); + + var query = { + url: pastedData.trim() + }; + var content = ''; + var index = 0; + + if (request && request.transport) { + request.transport.abort(); + } + + request = $.ajax({ + crossOrigin: true, + url: endpoints[index], + type: 'GET', + data: query, + cache: false, + dataType: 'jsonp', + success: function(res) { + if (res.html) { + index = 0; + content = res.html; + } else { + index += 1; + } + }, + error: function() { + index += 1; + }, + complete: function() { + if (content.length === 0 && index < endpoints.length - 1) { + this.url = endpoints[index]; + this.data = query; + $.ajax(this); + } + if (index === endpoints.length - 1) { + content = $('', { + href: pastedData, + text: pastedData + }).prop('outerHTML'); + } + if (content.length > 0) { + index = 0; + trumbowyg.execCmd('insertHTML', content); + } + } + }); + } + } catch (c) {} + }); + } + } + } + }); +})(jQuery); diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/pasteembed/trumbowyg.pasteembed.min.js b/vasl_templates/webapp/static/trumbowyg/plugins/pasteembed/trumbowyg.pasteembed.min.js new file mode 100644 index 0000000..fc8d530 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/pasteembed/trumbowyg.pasteembed.min.js @@ -0,0 +1,10 @@ +/* =========================================================== + * trumbowyg.pasteembed.js v1.0 + * Url paste to iframe with noembed. Plugin for Trumbowyg + * http://alex-d.github.com/Trumbowyg + * =========================================================== + * Author : Max Seelig + * Facebook : https://facebook.com/maxse + * Website : https://www.maxmade.nl/ + */ +!function(t){"use strict";var e={enabled:!0,endpoints:["https://noembed.com/embed?nowrap=on","https://api.maxmade.nl/url2iframe/embed"]};t.extend(!0,t.trumbowyg,{plugins:{pasteEmbed:{init:function(n){n.o.plugins.pasteEmbed=t.extend(!0,{},e,n.o.plugins.pasteEmbed||{}),n.o.plugins.pasteEmbed.enabled&&n.pasteHandlers.push((function(e){try{var a=(e.originalEvent||e).clipboardData.getData("Text"),r=n.o.plugins.pasteEmbed.endpoints,s=null;if(a.startsWith("http")){e.stopPropagation(),e.preventDefault();var i={url:a.trim()},o="",p=0;s&&s.transport&&s.transport.abort(),s=t.ajax({crossOrigin:!0,url:r[p],type:"GET",data:i,cache:!1,dataType:"jsonp",success:function(t){t.html?(p=0,o=t.html):p+=1},error:function(){p+=1},complete:function(){0===o.length&&p",{href:a,text:a}).prop("outerHTML")),o.length>0&&(p=0,n.execCmd("insertHTML",o))}})}}catch(t){}}))}}}})}(jQuery); \ No newline at end of file diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.js b/vasl_templates/webapp/static/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.js new file mode 100644 index 0000000..1969888 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.js @@ -0,0 +1,49 @@ +/* =========================================================== + * trumbowyg.pasteimage.js v1.0 + * Basic base64 paste plugin for Trumbowyg + * http://alex-d.github.com/Trumbowyg + * =========================================================== + * Author : Alexandre Demode (Alex-D) + * Twitter : @AlexandreDemode + * Website : alex-d.fr + */ + +(function ($) { + 'use strict'; + + $.extend(true, $.trumbowyg, { + plugins: { + pasteImage: { + init: function (trumbowyg) { + trumbowyg.pasteHandlers.push(function (pasteEvent) { + try { + var items = (pasteEvent.originalEvent || pasteEvent).clipboardData.items, + mustPreventDefault = false, + reader; + + for (var i = items.length - 1; i >= 0; i -= 1) { + if (items[i].type.match(/^image\//)) { + reader = new FileReader(); + /* jshint -W083 */ + reader.onloadend = function (event) { + trumbowyg.execCmd('insertImage', event.target.result, false, true); + }; + /* jshint +W083 */ + reader.readAsDataURL(items[i].getAsFile()); + + mustPreventDefault = true; + } + } + + if (mustPreventDefault) { + pasteEvent.stopPropagation(); + pasteEvent.preventDefault(); + } + } catch (c) { + } + }); + } + } + } + }); +})(jQuery); diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.min.js b/vasl_templates/webapp/static/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.min.js new file mode 100644 index 0000000..01744f9 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/pasteimage/trumbowyg.pasteimage.min.js @@ -0,0 +1,10 @@ +/* =========================================================== + * trumbowyg.pasteimage.js v1.0 + * Basic base64 paste plugin for Trumbowyg + * http://alex-d.github.com/Trumbowyg + * =========================================================== + * Author : Alexandre Demode (Alex-D) + * Twitter : @AlexandreDemode + * Website : alex-d.fr + */ +!function(e){"use strict";e.extend(!0,e.trumbowyg,{plugins:{pasteImage:{init:function(e){e.pasteHandlers.push((function(t){try{for(var a,n=(t.originalEvent||t).clipboardData.items,i=!1,r=n.length-1;r>=0;r-=1)n[r].type.match(/^image\//)&&((a=new FileReader).onloadend=function(t){e.execCmd("insertImage",t.target.result,!1,!0)},a.readAsDataURL(n[r].getAsFile()),i=!0);i&&(t.stopPropagation(),t.preventDefault())}catch(e){}}))}}}})}(jQuery); \ No newline at end of file diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/preformatted/trumbowyg.preformatted.js b/vasl_templates/webapp/static/trumbowyg/plugins/preformatted/trumbowyg.preformatted.js new file mode 100644 index 0000000..5c866ff --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/preformatted/trumbowyg.preformatted.js @@ -0,0 +1,151 @@ +/* =========================================================== + * trumbowyg.preformatted.js v1.0 + * Preformatted plugin for Trumbowyg + * http://alex-d.github.com/Trumbowyg + * =========================================================== + * Author : Casella Edoardo (Civile) + */ + + +(function ($) { + 'use strict'; + + $.extend(true, $.trumbowyg, { + langs: { + // jshint camelcase:false + en: { + preformatted: 'Code sample
'
+            },
+            by: {
+                preformatted: 'Прыклад кода 
'
+            },
+            da: {
+                preformatted: 'Præformateret 
'
+            },
+            et: {
+                preformatted: 'Eelvormindatud tekst 
'
+            },
+            fr: {
+                preformatted: 'Exemple de code 
'
+            },
+            hu: {
+                preformatted: 'Kód minta 
'
+            },
+            it: {
+                preformatted: 'Codice 
'
+            },
+            ja: {
+                preformatted: 'コードサンプル 
'
+            },
+            ko: {
+                preformatted: '코드 예제 
'
+            },
+            pt_br: {
+                preformatted: 'Exemple de código 
'
+            },
+            ru: {
+                preformatted: 'Пример кода 
'
+            },
+            tr: {
+                preformatted: 'Kod örneği 
'
+            },
+            zh_cn: {
+                preformatted: '代码示例 
'
+            },
+            zh_tw: {
+                preformatted: '代碼範例 
'
+            },
+        },
+        // jshint camelcase:true
+
+        plugins: {
+            preformatted: {
+                init: function (trumbowyg) {
+                    var btnDef = {
+                        fn: function () {
+                            trumbowyg.saveRange();
+                            var text = trumbowyg.getRangeText();
+                            if (text.replace(/\s/g, '') !== '') {
+                                try {
+                                    var curtag = getSelectionParentElement().tagName.toLowerCase();
+                                    if (curtag === 'code' || curtag === 'pre') {
+                                        return unwrapCode();
+                                    }
+                                    else {
+                                        trumbowyg.execCmd('insertHTML', '
' + strip(text) + '
'); + } + } catch (e) { + } + } + }, + tag: 'pre' + }; + + trumbowyg.addBtnDef('preformatted', btnDef); + } + } + } + }); + + /* + * GetSelectionParentElement + */ + function getSelectionParentElement() { + var parentEl = null, + selection; + + if (window.getSelection) { + selection = window.getSelection(); + if (selection.rangeCount) { + parentEl = selection.getRangeAt(0).commonAncestorContainer; + if (parentEl.nodeType !== 1) { + parentEl = parentEl.parentNode; + } + } + } else if ((selection = document.selection) && selection.type !== 'Control') { + parentEl = selection.createRange().parentElement(); + } + + return parentEl; + } + + /* + * Strip + * returns a text without HTML tags + */ + function strip(html) { + var tmp = document.createElement('DIV'); + tmp.innerHTML = html; + return tmp.textContent || tmp.innerText || ''; + } + + /* + * UnwrapCode + * ADD/FIX: to improve, works but can be better + * "paranoic" solution + */ + function unwrapCode() { + var container = null; + + if (document.selection) { //for IE + container = document.selection.createRange().parentElement(); + } else { + var select = window.getSelection(); + if (select.rangeCount > 0) { + container = select.getRangeAt(0).startContainer.parentNode; + } + } + + //'paranoic' unwrap + var ispre = $(container).contents().closest('pre').length; + var iscode = $(container).contents().closest('code').length; + + if (ispre && iscode) { + $(container).contents().unwrap('code').unwrap('pre'); + } else if (ispre) { + $(container).contents().unwrap('pre'); + } else if (iscode) { + $(container).contents().unwrap('code'); + } + } +})(jQuery); diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/preformatted/trumbowyg.preformatted.min.js b/vasl_templates/webapp/static/trumbowyg/plugins/preformatted/trumbowyg.preformatted.min.js new file mode 100644 index 0000000..8d47981 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/preformatted/trumbowyg.preformatted.min.js @@ -0,0 +1,8 @@ +/* =========================================================== + * trumbowyg.preformatted.js v1.0 + * Preformatted plugin for Trumbowyg + * http://alex-d.github.com/Trumbowyg + * =========================================================== + * Author : Casella Edoardo (Civile) + */ +!function(e){"use strict";e.extend(!0,e.trumbowyg,{langs:{en:{preformatted:"Code sample
"},by:{preformatted:"Прыклад кода 
"},da:{preformatted:"Præformateret 
"},et:{preformatted:"Eelvormindatud tekst 
"},fr:{preformatted:"Exemple de code 
"},hu:{preformatted:"Kód minta 
"},it:{preformatted:"Codice 
"},ja:{preformatted:"コードサンプル 
"},ko:{preformatted:"코드 예제 
"},pt_br:{preformatted:"Exemple de código 
"},ru:{preformatted:"Пример кода 
"},tr:{preformatted:"Kod örneği 
"},zh_cn:{preformatted:"代码示例 
"},zh_tw:{preformatted:"代碼範例 
"}},plugins:{preformatted:{init:function(t){var r={fn:function(){t.saveRange();var r,n,o=t.getRangeText();if(""!==o.replace(/\s/g,""))try{var a=function(){var e,t=null;window.getSelection?(e=window.getSelection()).rangeCount&&1!==(t=e.getRangeAt(0).commonAncestorContainer).nodeType&&(t=t.parentNode):(e=document.selection)&&"Control"!==e.type&&(t=e.createRange().parentElement());return t}().tagName.toLowerCase();if("code"===a||"pre"===a)return function(){var t=null;if(document.selection)t=document.selection.createRange().parentElement();else{var r=window.getSelection();r.rangeCount>0&&(t=r.getRangeAt(0).startContainer.parentNode)}var n=e(t).contents().closest("pre").length,o=e(t).contents().closest("code").length;n&&o?e(t).contents().unwrap("code").unwrap("pre"):n?e(t).contents().unwrap("pre"):o&&e(t).contents().unwrap("code")}();t.execCmd("insertHTML","
"+(r=o,(n=document.createElement("DIV")).innerHTML=r,(n.textContent||n.innerText||"")+"
"))}catch(e){}},tag:"pre"};t.addBtnDef("preformatted",r)}}}})}(jQuery); \ No newline at end of file diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/resizimg/trumbowyg.resizimg.js b/vasl_templates/webapp/static/trumbowyg/plugins/resizimg/trumbowyg.resizimg.js new file mode 100644 index 0000000..7870e9f --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/resizimg/trumbowyg.resizimg.js @@ -0,0 +1,311 @@ +; (function ($) { + 'use strict'; + + var defaultOptions = { + minSize: 32, + step: 4 + }; + + function preventDefault(e) { + e.stopPropagation(); + e.preventDefault(); + } + + var ResizeWithCanvas = function (trumbowyg) { + // variable to create canvas and save img in resize mode + this.resizeCanvas = document.createElement('canvas'); + // to allow canvas to get focus + this.resizeCanvas.setAttribute('tabindex', '0'); + this.resizeCanvas.id = 'trumbowyg-resizimg-' + (+new Date()); + this.ctx = null; + this.resizeImg = null; + + this.pressEscape = function (obj) { + obj.reset(); + }; + this.pressBackspaceOrDelete = function (obj) { + $(obj.resizeCanvas).remove(); + obj.resizeImg = null; + if (trumbowyg !== null){ + trumbowyg.syncCode(); + // notify changes + trumbowyg.$c.trigger('tbwchange'); + } + }; + + // PRIVATE FUNCTION + var focusedNow = false; + var isCursorSeResize = false; + + // calculate offset to change mouse over square in the canvas + var offsetX, offsetY; + var reOffset = function (canvas) { + var BB = canvas.getBoundingClientRect(); + offsetX = BB.left; + offsetY = BB.top; + }; + + var updateCanvas = function (canvas, ctx, img, canvasWidth, canvasHeight) { + ctx.translate(0.5, 0.5); + ctx.lineWidth = 1; + + // image + ctx.drawImage(img, 5, 5, canvasWidth - 10, canvasHeight - 10); + + // border + ctx.beginPath(); + ctx.rect(5, 5, canvasWidth - 10, canvasHeight - 10); + ctx.stroke(); + + // square in the angle + ctx.beginPath(); + ctx.fillStyle = 'rgb(255, 255, 255)'; + ctx.rect(canvasWidth - 10, canvasHeight - 10, 9, 9); + ctx.fill(); + ctx.stroke(); + + // get the offset to change the mouse cursor + reOffset(canvas); + + return ctx; + }; + + // PUBLIC FUNCTION + // necessary to correctly print cursor over square. Called once for instance. Useless with trumbowyg. + this.init = function () { + var _this = this; + $(window).on('scroll resize', function () { + _this.reCalcOffset(); + }); + }; + + this.reCalcOffset = function () { + reOffset(this.resizeCanvas); + }; + + this.canvasId = function () { + return this.resizeCanvas.id; + }; + + this.isActive = function () { + return this.resizeImg !== null; + }; + + this.isFocusedNow = function () { + return focusedNow; + }; + + this.blurNow = function () { + focusedNow = false; + }; + + // restore image in the HTML of the editor + this.reset = function () { + if (this.resizeImg === null) { + return; + } + + // set style of image to avoid issue on resize because this attribute have priority over width and height attribute + this.resizeImg.setAttribute('style', 'width: 100%; max-width: ' + (this.resizeCanvas.clientWidth - 10) + 'px; height: auto; max-height: ' + (this.resizeCanvas.clientHeight - 10) + 'px;'); + + $(this.resizeCanvas).replaceWith($(this.resizeImg)); + + // reset canvas style + this.resizeCanvas.removeAttribute('style'); + this.resizeImg = null; + }; + + // setup canvas with points and border to allow the resizing operation + this.setup = function (img, resizableOptions) { + this.resizeImg = img; + + if (!this.resizeCanvas.getContext) { + return false; + } + + focusedNow = true; + + // draw canvas + this.resizeCanvas.width = $(this.resizeImg).width() + 10; + this.resizeCanvas.height = $(this.resizeImg).height() + 10; + this.resizeCanvas.style.margin = '-5px'; + this.ctx = this.resizeCanvas.getContext('2d'); + + // replace image with canvas + $(this.resizeImg).replaceWith($(this.resizeCanvas)); + + updateCanvas(this.resizeCanvas, this.ctx, this.resizeImg, this.resizeCanvas.width, this.resizeCanvas.height); + + // enable resize + $(this.resizeCanvas).resizableSafe(resizableOptions) + .on('mousedown', preventDefault); + + var _this = this; + $(this.resizeCanvas) + .on('mousemove', function (e) { + var mouseX = Math.round(e.clientX - offsetX); + var mouseY = Math.round(e.clientY - offsetY); + + var wasCursorSeResize = isCursorSeResize; + + _this.ctx.rect(_this.resizeCanvas.width - 10, _this.resizeCanvas.height - 10, 9, 9); + isCursorSeResize = _this.ctx.isPointInPath(mouseX, mouseY); + if (wasCursorSeResize !== isCursorSeResize) { + this.style.cursor = isCursorSeResize ? 'se-resize' : 'default'; + } + }) + .on('keydown', function (e) { + if (!_this.isActive()) { + return; + } + + var x = e.keyCode; + if (x === 27) { // ESC + _this.pressEscape(_this); + } else if (x === 8 || x === 46) { // BACKSPACE or DELETE + _this.pressBackspaceOrDelete(_this); + } + }) + .on('focus', preventDefault) + .on('blur', function () { + _this.reset(); + // save changes + if (trumbowyg !== null){ + trumbowyg.syncCode(); + // notify changes + trumbowyg.$c.trigger('tbwchange'); + } + }); + + this.resizeCanvas.focus(); + + return true; + }; + + // update the canvas after the resizing + this.refresh = function () { + if (!this.resizeCanvas.getContext) { + return; + } + + this.resizeCanvas.width = this.resizeCanvas.clientWidth; + this.resizeCanvas.height = this.resizeCanvas.clientHeight; + updateCanvas(this.resizeCanvas, this.ctx, this.resizeImg, this.resizeCanvas.width, this.resizeCanvas.height); + }; + }; + + $.extend(true, $.trumbowyg, { + plugins: { + resizimg: { + destroyResizable: function () {}, + init: function (trumbowyg) { + var destroyResizable = this.destroyResizable; + + // object to interact with canvas + var resizeWithCanvas = new ResizeWithCanvas(trumbowyg); + + this.destroyResizable = function () { + // clean html code + trumbowyg.$ed.find('canvas.resizable') + .resizableSafe('destroy') + .off('mousedown', preventDefault) + .removeClass('resizable'); + + resizeWithCanvas.reset(); + + trumbowyg.syncCode(); + }; + + trumbowyg.o.plugins.resizimg = $.extend(true, {}, + defaultOptions, + trumbowyg.o.plugins.resizimg || {}, + { + resizable: { + resizeWidth: false, + onDragStart: function (ev, $el) { + var opt = trumbowyg.o.plugins.resizimg; + var x = ev.pageX - $el.offset().left; + var y = ev.pageY - $el.offset().top; + if (x < $el.width() - opt.minSize || y < $el.height() - opt.minSize) { + return false; + } + }, + onDrag: function (ev, $el, newWidth, newHeight) { + var opt = trumbowyg.o.plugins.resizimg; + if (newHeight < opt.minSize) { + newHeight = opt.minSize; + } + newHeight -= newHeight % opt.step; + $el.height(newHeight); + return false; + }, + onDragEnd: function () { + // resize update canvas information + resizeWithCanvas.refresh(); + trumbowyg.syncCode(); + } + } + } + ); + + function initResizable() { + trumbowyg.$ed.find('img') + .off('click') + .on('click', function (e) { + // if I'm already do a resize, reset it + if (resizeWithCanvas.isActive()) { + resizeWithCanvas.reset(); + } + // initialize resize of image + resizeWithCanvas.setup(this, trumbowyg.o.plugins.resizimg.resizable); + + preventDefault(e); + }); + } + + trumbowyg.$c.on('tbwinit', function () { + initResizable(); + + // disable resize when click on other items + trumbowyg.$ed.on('click', function (e) { + // check if I've clicked out of canvas or image to reset it + if ($(e.target).is('img') || e.target.id === resizeWithCanvas.canvasId()) { + return; + } + + preventDefault(e); + resizeWithCanvas.reset(); + //sync + trumbowyg.syncCode(); + // notify changes + trumbowyg.$c.trigger('tbwchange'); + }); + + trumbowyg.$ed.on('scroll', function () { + resizeWithCanvas.reCalcOffset(); + }); + }); + + trumbowyg.$c.on('tbwfocus tbwchange', initResizable); + trumbowyg.$c.on('tbwresize', function () { + resizeWithCanvas.reCalcOffset(); + }); + + // Destroy + trumbowyg.$c.on('tbwblur', function () { + // when canvas is created the tbwblur is called + // this code avoid to destroy the canvas that allow the image resizing + if (resizeWithCanvas.isFocusedNow()) { + resizeWithCanvas.blurNow(); + } else { + destroyResizable(); + } + }); + }, + destroy: function () { + this.destroyResizable(); + } + } + } + }); +})(jQuery); diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/resizimg/trumbowyg.resizimg.min.js b/vasl_templates/webapp/static/trumbowyg/plugins/resizimg/trumbowyg.resizimg.min.js new file mode 100644 index 0000000..0345d21 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/resizimg/trumbowyg.resizimg.min.js @@ -0,0 +1,3 @@ +!function(e){"use strict";var i={minSize:32,step:4};function t(e){e.stopPropagation(),e.preventDefault()}var s=function(i){this.resizeCanvas=document.createElement("canvas"),this.resizeCanvas.setAttribute("tabindex","0"),this.resizeCanvas.id="trumbowyg-resizimg-"+ +new Date,this.ctx=null,this.resizeImg=null,this.pressEscape=function(e){e.reset()},this.pressBackspaceOrDelete=function(t){e(t.resizeCanvas).remove(),t.resizeImg=null,null!==i&&(i.syncCode(),i.$c.trigger("tbwchange"))};var s,n,r=!1,a=!1,o=function(e){var i=e.getBoundingClientRect();s=i.left,n=i.top},h=function(e,i,t,s,n){return i.translate(.5,.5),i.lineWidth=1,i.drawImage(t,5,5,s-10,n-10),i.beginPath(),i.rect(5,5,s-10,n-10),i.stroke(),i.beginPath(),i.fillStyle="rgb(255, 255, 255)",i.rect(s-10,n-10,9,9),i.fill(),i.stroke(),o(e),i}; +// necessary to correctly print cursor over square. Called once for instance. Useless with trumbowyg. +this.init=function(){var i=this;e(window).on("scroll resize",(function(){i.reCalcOffset()}))},this.reCalcOffset=function(){o(this.resizeCanvas)},this.canvasId=function(){return this.resizeCanvas.id},this.isActive=function(){return null!==this.resizeImg},this.isFocusedNow=function(){return r},this.blurNow=function(){r=!1},this.reset=function(){null!==this.resizeImg&&(this.resizeImg.setAttribute("style","width: 100%; max-width: "+(this.resizeCanvas.clientWidth-10)+"px; height: auto; max-height: "+(this.resizeCanvas.clientHeight-10)+"px;"),e(this.resizeCanvas).replaceWith(e(this.resizeImg)),this.resizeCanvas.removeAttribute("style"),this.resizeImg=null)},this.setup=function(o,c){if(this.resizeImg=o,!this.resizeCanvas.getContext)return!1;r=!0,this.resizeCanvas.width=e(this.resizeImg).width()+10,this.resizeCanvas.height=e(this.resizeImg).height()+10,this.resizeCanvas.style.margin="-5px",this.ctx=this.resizeCanvas.getContext("2d"),e(this.resizeImg).replaceWith(e(this.resizeCanvas)),h(this.resizeCanvas,this.ctx,this.resizeImg,this.resizeCanvas.width,this.resizeCanvas.height),e(this.resizeCanvas).resizableSafe(c).on("mousedown",t);var u=this;return e(this.resizeCanvas).on("mousemove",(function(e){var i=Math.round(e.clientX-s),t=Math.round(e.clientY-n),r=a;u.ctx.rect(u.resizeCanvas.width-10,u.resizeCanvas.height-10,9,9),r!==(a=u.ctx.isPointInPath(i,t))&&(this.style.cursor=a?"se-resize":"default")})).on("keydown",(function(e){if(u.isActive()){var i=e.keyCode;27===i?u.pressEscape(u):8!==i&&46!==i||u.pressBackspaceOrDelete(u)}})).on("focus",t).on("blur",(function(){u.reset(),null!==i&&(i.syncCode(),i.$c.trigger("tbwchange"))})),this.resizeCanvas.focus(),!0},this.refresh=function(){this.resizeCanvas.getContext&&(this.resizeCanvas.width=this.resizeCanvas.clientWidth,this.resizeCanvas.height=this.resizeCanvas.clientHeight,h(this.resizeCanvas,this.ctx,this.resizeImg,this.resizeCanvas.width,this.resizeCanvas.height))}};e.extend(!0,e.trumbowyg,{plugins:{resizimg:{destroyResizable:function(){},init:function(n){var r=this.destroyResizable,a=new s(n);function o(){n.$ed.find("img").off("click").on("click",(function(e){a.isActive()&&a.reset(),a.setup(this,n.o.plugins.resizimg.resizable),t(e)}))}this.destroyResizable=function(){n.$ed.find("canvas.resizable").resizableSafe("destroy").off("mousedown",t).removeClass("resizable"),a.reset(),n.syncCode()},n.o.plugins.resizimg=e.extend(!0,{},i,n.o.plugins.resizimg||{},{resizable:{resizeWidth:!1,onDragStart:function(e,i){var t=n.o.plugins.resizimg,s=e.pageX-i.offset().left,r=e.pageY-i.offset().top;if(s' + v.modal + ' (' + v.rubyText + ')')[0]; + trumbowyg.range.deleteContents(); + trumbowyg.range.insertNode(node); + trumbowyg.syncCode(); + trumbowyg.$c.trigger('tbwchange'); + return true; + } + ); + } + }; + trumbowyg.addBtnDef('ruby', btnDef); + } + } + } + }); +})(jQuery); diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/ruby/trumbowyg.ruby.min.js b/vasl_templates/webapp/static/trumbowyg/plugins/ruby/trumbowyg.ruby.min.js new file mode 100644 index 0000000..997e690 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/ruby/trumbowyg.ruby.min.js @@ -0,0 +1,10 @@ +/* =========================================================== + * trumbowyg.ruby.js v1.0 + * Ruby text plugin for Trumbowyg + * http://alex-d.github.com/Trumbowyg + * =========================================================== + * Author : Fathi Anshory (0x00000F5C) + * Twitter : @fscchannl + * Comment : Since I use trumbowyg in my project and required it to insert ruby text, so I thought I can contribute a little. :D + */ +!function(u){"use strict";u.extend(!0,u.trumbowyg,{langs:{en:{ruby:"Add ruby text",rubyModal:"Ruby modal",rubyText:"Ruby text"},by:{ruby:"Уставіць ruby тэкст",rubyModal:"Ruby анатацыя",rubyText:"Ruby тэкст"},da:{ruby:"Tilføj ruby tekst",rubyModal:"Ruby modal",rubyText:"Ruby tekst"},et:{ruby:"Lisa ruby tekst",rubyModal:"Ruby modaal",rubyText:"Ruby tekst"},fr:{ruby:"Ajouter du texte ruby",rubyModal:"Modale ruby",rubyText:"Texte ruby"},hu:{ruby:"Ruby szöveg hozzáadás",rubyModal:"Ruby modal",rubyText:"Ruby szöveg"},id:{ruby:"Sisipkan teks ruby",rubyModal:"Modal teks ruby",rubyText:"Teks ruby"},ko:{ruby:"루비 문자 넣기",rubyModal:"대상 문자",rubyText:"루비 문자"},pt_br:{ruby:"Adicionar texto ruby",rubyModal:"Modal ruby",rubyText:"Texto ruby"},ru:{ruby:"Вставить ruby текст",rubyModal:"Ruby аннотация",rubyText:"Ruby текст"},tr:{ruby:"Ruby metni ekle",rubyModal:"Ruby modal",rubyText:"Ruby metni"},zh_tw:{ruby:"加入 ruby 文字",rubyModal:"Ruby 彈跳視窗",rubyText:"Ruby 文字"}},plugins:{ruby:{init:function(r){var b={fn:function(){r.saveRange(),r.openModalInsert(r.lang.ruby,{rubyText:{label:r.lang.rubyText,required:!1},modal:{label:r.lang.rubyModal,value:r.getRangeText(),required:!0}},(function(b){var y=u(''+b.modal+" ("+b.rubyText+")")[0];return r.range.deleteContents(),r.range.insertNode(y),r.syncCode(),r.$c.trigger("tbwchange"),!0}))}};r.addBtnDef("ruby",b)}}}})}(jQuery); \ No newline at end of file diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/specialchars/trumbowyg.specialchars.js b/vasl_templates/webapp/static/trumbowyg/plugins/specialchars/trumbowyg.specialchars.js new file mode 100644 index 0000000..b2af0d7 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/specialchars/trumbowyg.specialchars.js @@ -0,0 +1,94 @@ +/* =========================================================== + * trumbowyg.specialchars.js v0.99 + * Unicode characters picker plugin for Trumbowyg + * http://alex-d.github.com/Trumbowyg + * =========================================================== + * Author : Renaud Hoyoux (geektortoise) +*/ + +(function ($) { + 'use strict'; + + var defaultOptions = { + symbolList: [ + // currencies + '0024', '20AC', '00A3', '00A2', '00A5', '00A4', '2030', null, + // legal signs + '00A9', '00AE', '2122', null, + // textual sign + '00A7', '00B6', '00C6', '00E6', '0152', '0153', null, + '2022', '25CF', '2023', '25B6', '2B29', '25C6', null, + //maths + '00B1', '00D7', '00F7', '21D2', '21D4', '220F', '2211', '2243', '2264', '2265' + ] + }; + + $.extend(true, $.trumbowyg, { + langs: { + en: { + specialChars: 'Special characters' + }, + by: { + specialChars: 'Спецыяльныя сімвалы' + }, + et: { + specialChars: 'Erimärgid' + }, + fr: { + specialChars: 'Caractères spéciaux' + }, + hu: { + specialChars: 'Speciális karakterek' + }, + ko: { + specialChars: '특수문자' + }, + ru: { + specialChars: 'Специальные символы' + }, + tr: { + specialChars: 'Özel karakterler' + }, + }, + plugins: { + specialchars: { + init: function (trumbowyg) { + trumbowyg.o.plugins.specialchars = trumbowyg.o.plugins.specialchars || defaultOptions; + var specialCharsBtnDef = { + dropdown: buildDropdown(trumbowyg) + }; + + trumbowyg.addBtnDef('specialChars', specialCharsBtnDef); + } + } + } + }); + + function buildDropdown(trumbowyg) { + var dropdown = []; + $.each(trumbowyg.o.plugins.specialchars.symbolList, function (i, symbol) { + if (symbol === null) { + symbol = ' '; + } else { + symbol = '&#x' + symbol; + } + + var btn = symbol.replace(/:/g, ''), + defaultSymbolBtnName = 'symbol-' + btn, + defaultSymbolBtnDef = { + text: symbol, + hasIcon: false, + fn: function () { + var encodedSymbol = String.fromCodePoint(parseInt(symbol.replace('&#', '0'))); + trumbowyg.execCmd('insertText', encodedSymbol); + return true; + } + }; + + trumbowyg.addBtnDef(defaultSymbolBtnName, defaultSymbolBtnDef); + dropdown.push(defaultSymbolBtnName); + }); + + return dropdown; + } +})(jQuery); diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/specialchars/trumbowyg.specialchars.min.js b/vasl_templates/webapp/static/trumbowyg/plugins/specialchars/trumbowyg.specialchars.min.js new file mode 100644 index 0000000..0b637ff --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/specialchars/trumbowyg.specialchars.min.js @@ -0,0 +1,8 @@ +/* =========================================================== + * trumbowyg.specialchars.js v0.99 + * Unicode characters picker plugin for Trumbowyg + * http://alex-d.github.com/Trumbowyg + * =========================================================== + * Author : Renaud Hoyoux (geektortoise) +*/ +!function(a){"use strict";var s={symbolList:["0024","20AC","00A3","00A2","00A5","00A4","2030",null,"00A9","00AE","2122",null,"00A7","00B6","00C6","00E6","0152","0153",null,"2022","25CF","2023","25B6","2B29","25C6",null,"00B1","00D7","00F7","21D2","21D4","220F","2211","2243","2264","2265"]};function r(s){var r=[];return a.each(s.o.plugins.specialchars.symbolList,(function(a,e){var l="symbol-"+(e=null===e?" ":"&#x"+e).replace(/:/g,""),i={text:e,hasIcon:!1,fn:function(){var a=String.fromCodePoint(parseInt(e.replace("&#","0")));return s.execCmd("insertText",a),!0}};s.addBtnDef(l,i),r.push(l)})),r}a.extend(!0,a.trumbowyg,{langs:{en:{specialChars:"Special characters"},by:{specialChars:"Спецыяльныя сімвалы"},et:{specialChars:"Erimärgid"},fr:{specialChars:"Caractères spéciaux"},hu:{specialChars:"Speciális karakterek"},ko:{specialChars:"특수문자"},ru:{specialChars:"Специальные символы"},tr:{specialChars:"Özel karakterler"}},plugins:{specialchars:{init:function(a){a.o.plugins.specialchars=a.o.plugins.specialchars||s;var e={dropdown:r(a)};a.addBtnDef("specialChars",e)}}}})}(jQuery); \ No newline at end of file diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/specialchars/ui/sass/trumbowyg.specialchars.scss b/vasl_templates/webapp/static/trumbowyg/plugins/specialchars/ui/sass/trumbowyg.specialchars.scss new file mode 100644 index 0000000..6b2797b --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/specialchars/ui/sass/trumbowyg.specialchars.scss @@ -0,0 +1,56 @@ +/** + * Trumbowyg v2.25.2 - A lightweight WYSIWYG editor + * Default stylesheet for Trumbowyg editor plugin + * ------------------------ + * @link http://alex-d.github.io/Trumbowyg + * @license MIT + * @author Alexandre Demode (Alex-D) + * Twitter : @AlexandreDemode + * Website : alex-d.fr + */ + +.trumbowyg-symbol-\ -dropdown-button { + display: none !important; +} +.trumbowyg-symbol-\ -dropdown-button + button { + clear: both; +} + +.trumbowyg-dropdown-specialChars { + width: 248px; + padding: 5px 3px 3px; +} + +.trumbowyg-dropdown-specialChars button { + display: block; + position: relative; + float: left; + height: 26px; + width: 26px; + padding: 0; + margin: 2px; + line-height: 24px; + text-align: center; + + &:hover, + &:focus { + &::after { + display: block; + position: absolute; + top: -5px; + left: -5px; + height: 27px; + width: 27px; + background: inherit; + box-shadow: #000 0 0 2px; + z-index: 10; + background-color: transparent; + } + } +} + +.trumbowyg .specialChars { + width: 22px; + height: 22px; + display: inline-block; +} diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/specialchars/ui/trumbowyg.specialchars.css b/vasl_templates/webapp/static/trumbowyg/plugins/specialchars/ui/trumbowyg.specialchars.css new file mode 100644 index 0000000..22c5887 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/specialchars/ui/trumbowyg.specialchars.css @@ -0,0 +1,48 @@ +/** + * Trumbowyg v2.25.2 - A lightweight WYSIWYG editor + * Trumbowyg plugin stylesheet + * ------------------------ + * @link http://alex-d.github.io/Trumbowyg + * @license MIT + * @author Alexandre Demode (Alex-D) + * Twitter : @AlexandreDemode + * Website : alex-d.fr + */ + +.trumbowyg-symbol-\ -dropdown-button { + display: none !important; } + +.trumbowyg-symbol-\ -dropdown-button + button { + clear: both; } + +.trumbowyg-dropdown-specialChars { + width: 248px; + padding: 5px 3px 3px; } + +.trumbowyg-dropdown-specialChars button { + display: block; + position: relative; + float: left; + height: 26px; + width: 26px; + padding: 0; + margin: 2px; + line-height: 24px; + text-align: center; } + .trumbowyg-dropdown-specialChars button:hover::after, .trumbowyg-dropdown-specialChars button:focus::after { + display: block; + position: absolute; + top: -5px; + left: -5px; + height: 27px; + width: 27px; + background: inherit; + -webkit-box-shadow: #000 0 0 2px; + box-shadow: #000 0 0 2px; + z-index: 10; + background-color: transparent; } + +.trumbowyg .specialChars { + width: 22px; + height: 22px; + display: inline-block; } diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/specialchars/ui/trumbowyg.specialchars.min.css b/vasl_templates/webapp/static/trumbowyg/plugins/specialchars/ui/trumbowyg.specialchars.min.css new file mode 100644 index 0000000..9a3a393 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/specialchars/ui/trumbowyg.specialchars.min.css @@ -0,0 +1,2 @@ +/** Trumbowyg v2.25.2 - A lightweight WYSIWYG editor - alex-d.github.io/Trumbowyg - License MIT - Author : Alexandre Demode (Alex-D) / alex-d.fr */ +.trumbowyg-symbol-\ -dropdown-button{display:none!important}.trumbowyg-symbol-\ -dropdown-button+button{clear:both}.trumbowyg-dropdown-specialChars{width:248px;padding:5px 3px 3px}.trumbowyg-dropdown-specialChars button{display:block;position:relative;float:left;height:26px;width:26px;padding:0;margin:2px;line-height:24px;text-align:center}.trumbowyg-dropdown-specialChars button:focus::after,.trumbowyg-dropdown-specialChars button:hover::after{display:block;position:absolute;top:-5px;left:-5px;height:27px;width:27px;background:inherit;-webkit-box-shadow:#000 0 0 2px;box-shadow:#000 0 0 2px;z-index:10;background-color:transparent}.trumbowyg .specialChars{width:22px;height:22px;display:inline-block} \ No newline at end of file diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/table/trumbowyg.table.js b/vasl_templates/webapp/static/trumbowyg/plugins/table/trumbowyg.table.js new file mode 100644 index 0000000..4edc58a --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/table/trumbowyg.table.js @@ -0,0 +1,454 @@ +/* =========================================================== + * trumbowyg.table.custom.js v2.0 + * Table plugin for Trumbowyg + * http://alex-d.github.com/Trumbowyg + * =========================================================== + * Author : Sven Dunemann [dunemann@forelabs.eu] + */ + +(function ($) { + 'use strict'; + + var defaultOptions = { + rows: 8, + columns: 8, + styler: 'table' + }; + + $.extend(true, $.trumbowyg, { + langs: { + // jshint camelcase:false + en: { + table: 'Insert table', + tableAddRow: 'Add row', + tableAddRowAbove: 'Add row above', + tableAddColumnLeft: 'Add column to the left', + tableAddColumn: 'Add column to the right', + tableDeleteRow: 'Delete row', + tableDeleteColumn: 'Delete column', + tableDestroy: 'Delete table', + error: 'Error' + }, + cs: { + table: 'Vytvořit příkaz Table', + tableAddRow: 'Přidat řádek', + tableAddRowAbove: 'Přidat řádek', + tableAddColumnLeft: 'Přidat sloupec', + tableAddColumn: 'Přidat sloupec', + error: 'Chyba' + }, + da: { + table: 'Indsæt tabel', + tableAddRow: 'Tilføj række', + tableAddRowAbove: 'Tilføj række', + tableAddColumnLeft: 'Tilføj kolonne', + tableAddColumn: 'Tilføj kolonne', + tableDeleteRow: 'Slet række', + tableDeleteColumn: 'Slet kolonne', + tableDestroy: 'Slet tabel', + error: 'Fejl' + }, + de: { + table: 'Tabelle einfügen', + tableAddRow: 'Zeile hinzufügen', + tableAddRowAbove: 'Zeile hinzufügen', + tableAddColumnLeft: 'Spalte hinzufügen', + tableAddColumn: 'Spalte hinzufügen', + tableDeleteRow: 'Zeile löschen', + tableDeleteColumn: 'Spalte löschen', + tableDestroy: 'Tabelle löschen', + error: 'Error' + }, + et: { + table: 'Sisesta tabel', + tableAddRow: 'Lisa rida', + tableAddRowAbove: 'Lisa rida üles', + tableAddColumnLeft: 'Lisa tulp vasakule', + tableAddColumn: 'Lisa tulp paremale', + tableDeleteRow: 'Kustuta rida', + tableDeleteColumn: 'Kustuta tulp', + tableDestroy: 'Kustuta tabel', + error: 'Viga' + }, + fr: { + table: 'Insérer un tableau', + tableAddRow: 'Ajouter des lignes', + tableAddRowAbove: 'Ajouter des lignes', + tableAddColumnLeft: 'Ajouter des colonnes', + tableAddColumn: 'Ajouter des colonnes', + tableDeleteRow: 'Effacer la ligne', + tableDeleteColumn: 'Effacer la colonne', + tableDestroy: 'Effacer le tableau', + error: 'Erreur' + }, + hu: { + table: 'Táblázat beszúrás', + tableAddRow: 'Sor hozzáadás', + tableAddRowAbove: 'Sor beszúrás fönt', + tableAddColumnLeft: 'Sor beszúrás balra', + tableAddColumn: 'Sor beszúrás jobbra', + tableDeleteRow: 'Sor törlés', + tableDeleteColumn: 'Oszlop törlés', + tableDestroy: 'Táblázat törlés', + error: 'Hiba' + }, + id: { + table: 'Sisipkan tabel', + tableAddRow: 'Sisipkan baris', + tableAddRowAbove: 'Sisipkan baris', + tableAddColumnLeft: 'Sisipkan kolom', + tableAddColumn: 'Sisipkan kolom', + tableDeleteRow: 'Hapus baris', + tableDeleteColumn: 'Hapus kolom', + tableDestroy: 'Hapus tabel', + error: 'Galat' + }, + ja: { + table: '表の挿入', + tableAddRow: '行の追加', + tableAddRowAbove: '行の追加', + tableAddColumnLeft: '列の追加', + tableAddColumn: '列の追加', + error: 'エラー' + }, + ko: { + table: '표 넣기', + tableAddRow: '줄 추가', + tableAddRowAbove: '줄 추가', + tableAddColumnLeft: '칸 추가', + tableAddColumn: '칸 추가', + tableDeleteRow: '줄 삭제', + tableDeleteColumn: '칸 삭제', + tableDestroy: '표 지우기', + error: '에러' + }, + pt_br: { + table: 'Inserir tabela', + tableAddRow: 'Adicionar linha', + tableAddRowAbove: 'Adicionar linha', + tableAddColumnLeft: 'Adicionar coluna', + tableAddColumn: 'Adicionar coluna', + tableDeleteRow: 'Deletar linha', + tableDeleteColumn: 'Deletar coluna', + tableDestroy: 'Deletar tabela', + error: 'Erro' + }, + ru: { + table: 'Вставить таблицу', + tableAddRow: 'Добавить строку', + tableAddRowAbove: 'Добавить строку', + tableAddColumnLeft: 'Добавить столбец', + tableAddColumn: 'Добавить столбец', + tableDeleteRow: 'Удалить строку', + tableDeleteColumn: 'Удалить столбец', + tableDestroy: 'Удалить таблицу', + error: 'Ошибка' + }, + sk: { + table: 'Vytvoriť tabuľky', + tableAddRow: 'Pridať riadok', + tableAddRowAbove: 'Pridať riadok', + tableAddColumnLeft: 'Pridať stĺpec', + tableAddColumn: 'Pridať stĺpec', + error: 'Chyba' + }, + tr: { + table: 'Tablo ekle', + tableAddRow: 'Satır ekle', + tableAddRowAbove: 'Yukarıya satır ekle', + tableAddColumnLeft: 'Sola sütun ekle', + tableAddColumn: 'Sağa sütun ekle', + tableDeleteRow: 'Satırı sil', + tableDeleteColumn: 'Sütunu sil', + tableDestroy: 'Tabloyu sil', + error: 'Hata' + }, + zh_tw: { + table: '插入表格', + tableAddRow: '加入行', + tableAddRowAbove: '加入行', + tableAddColumnLeft: '加入列', + tableAddColumn: '加入列', + tableDeleteRow: '刪除行', + tableDeleteColumn: '刪除列', + tableDestroy: '刪除表格', + error: '錯誤' + }, + es: { + table: 'Insertar tabla', + tableAddRow: 'Agregar fila', + tableAddRowAbove: 'Agregar fila arriba', + tableAddColumnLeft: 'Agregar columna a la izquierda', + tableAddColumn: 'Agregar columna a la derecha', + tableDeleteRow: 'Borrar fila', + tableDeleteColumn: 'Borrar columna', + tableDestroy: 'Borrar tabla', + error: 'Error' + }// jshint camelcase:true + }, + + plugins: { + table: { + init: function (t) { + t.o.plugins.table = $.extend(true, {}, defaultOptions, t.o.plugins.table || {}); + + var buildButtonDef = { + fn: function () { + t.saveRange(); + + var btnName = 'table'; + + var dropdownPrefix = t.o.prefix + 'dropdown', + dropdownOptions = { // the dropdown + class: dropdownPrefix + '-' + btnName + ' ' + dropdownPrefix + ' ' + t.o.prefix + 'fixed-top' + }; + dropdownOptions['data-' + dropdownPrefix] = btnName; + var $dropdown = $('
', dropdownOptions); + + if (t.$box.find('.' + dropdownPrefix + '-' + btnName).length === 0) { + t.$box.append($dropdown.hide()); + } else { + $dropdown = t.$box.find('.' + dropdownPrefix + '-' + btnName); + } + + // clear dropdown + $dropdown.html(''); + + // when active table show AddRow / AddColumn + if (t.$box.find('.' + t.o.prefix + 'table-button').hasClass(t.o.prefix + 'active-button')) { + $dropdown.append(t.buildSubBtn('tableAddRowAbove')); + $dropdown.append(t.buildSubBtn('tableAddRow')); + $dropdown.append(t.buildSubBtn('tableAddColumnLeft')); + $dropdown.append(t.buildSubBtn('tableAddColumn')); + $dropdown.append(t.buildSubBtn('tableDeleteRow')); + $dropdown.append(t.buildSubBtn('tableDeleteColumn')); + $dropdown.append(t.buildSubBtn('tableDestroy')); + } else { + var tableSelect = $(''); + $('').appendTo(tableSelect); + for (var i = 0; i < t.o.plugins.table.rows; i += 1) { + var row = $('').appendTo(tableSelect); + for (var j = 0; j < t.o.plugins.table.columns; j += 1) { + $('
').appendTo(row); + } + } + tableSelect.find('td').on('mouseover', tableAnimate); + tableSelect.find('td').on('mousedown', tableBuild); + + $dropdown.append(tableSelect); + $dropdown.append($('
1x1
')); + } + + t.dropdown(btnName); + } + }; + + var tableAnimate = function(columnEvent) { + var column = $(columnEvent.target), + table = column.closest('table'), + colIndex = this.cellIndex, + rowIndex = this.parentNode.rowIndex; + + // reset all columns + table.find('td').removeClass('active'); + + for (var i = 0; i <= rowIndex; i += 1) { + for (var j = 0; j <= colIndex; j += 1) { + table.find('tr:nth-of-type('+(i+1)+')').find('td:nth-of-type('+(j+1)+')').addClass('active'); + } + } + + // set label + table.next('.trumbowyg-table-size').html((colIndex+1) + 'x' + (rowIndex+1)); + }; + + var tableBuild = function() { + t.saveRange(); + + var tabler = $(''); + $('').appendTo(tabler); + if (t.o.plugins.table.styler) { + tabler.attr('class', t.o.plugins.table.styler); + } + + var colIndex = this.cellIndex, + rowIndex = this.parentNode.rowIndex; + + for (var i = 0; i <= rowIndex; i += 1) { + var row = $('').appendTo(tabler); + for (var j = 0; j <= colIndex; j += 1) { + $(''); + // add columns according to current columns count + for (var i = 0; i < table.find('tr')[0].childElementCount; i += 1) { + $(''); + // add columns according to current columns count + for (var i = 0; i < table.find('tr')[0].childElementCount; i += 1) { + $(''); + }); + } + + t.syncCode(); + } + }; + + var addColumnLeft = { + title: t.lang.tableAddColumnLeft, + text: t.lang.tableAddColumnLeft, + ico: 'col-left', + + fn: function () { + t.saveRange(); + + var node = t.doc.getSelection().focusNode; + var focusedCol = $(node).closest('td'); + var table = $(node).closest('table'); + var focusedColIdx = focusedCol.index(); + + if(table.length > 0) { + $(table).find('tr').each(function() { + $($(this).children()[focusedColIdx]).before(''); + }); + } + + t.syncCode(); + } + }; + + var destroy = { + title: t.lang.tableDestroy, + text: t.lang.tableDestroy, + ico: 'table-delete', + + fn: function () { + t.saveRange(); + + var node = t.doc.getSelection().focusNode, + table = $(node).closest('table'); + + table.remove(); + + t.syncCode(); + } + }; + + var deleteRow = { + title: t.lang.tableDeleteRow, + text: t.lang.tableDeleteRow, + ico: 'row-delete', + + fn: function () { + t.saveRange(); + + var node = t.doc.getSelection().focusNode, + row = $(node).closest('tr'); + + row.remove(); + + t.syncCode(); + } + }; + + var deleteColumn = { + title: t.lang.tableDeleteColumn, + text: t.lang.tableDeleteColumn, + ico: 'col-delete', + + fn: function () { + t.saveRange(); + + var node = t.doc.getSelection().focusNode, + table = $(node).closest('table'), + td = $(node).closest('td'), + cellIndex = td.index(); + + $(table).find('tr').each(function() { + $(this).find('td:eq(' + cellIndex + ')').remove(); + }); + + t.syncCode(); + } + }; + + t.addBtnDef('table', buildButtonDef); + t.addBtnDef('tableAddRowAbove', addRowAbove); + t.addBtnDef('tableAddRow', addRow); + t.addBtnDef('tableAddColumnLeft', addColumnLeft); + t.addBtnDef('tableAddColumn', addColumn); + t.addBtnDef('tableDeleteRow', deleteRow); + t.addBtnDef('tableDeleteColumn', deleteColumn); + t.addBtnDef('tableDestroy', destroy); + } + } + } + }); +})(jQuery); diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/table/trumbowyg.table.min.js b/vasl_templates/webapp/static/trumbowyg/plugins/table/trumbowyg.table.min.js new file mode 100644 index 0000000..4222d10 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/table/trumbowyg.table.min.js @@ -0,0 +1,8 @@ +/* =========================================================== + * trumbowyg.table.custom.js v2.0 + * Table plugin for Trumbowyg + * http://alex-d.github.com/Trumbowyg + * =========================================================== + * Author : Sven Dunemann [dunemann@forelabs.eu] + */ +!function(e){"use strict";var t={rows:8,columns:8,styler:"table"};e.extend(!0,e.trumbowyg,{langs:{en:{table:"Insert table",tableAddRow:"Add row",tableAddRowAbove:"Add row above",tableAddColumnLeft:"Add column to the left",tableAddColumn:"Add column to the right",tableDeleteRow:"Delete row",tableDeleteColumn:"Delete column",tableDestroy:"Delete table",error:"Error"},cs:{table:"Vytvořit příkaz Table",tableAddRow:"Přidat řádek",tableAddRowAbove:"Přidat řádek",tableAddColumnLeft:"Přidat sloupec",tableAddColumn:"Přidat sloupec",error:"Chyba"},da:{table:"Indsæt tabel",tableAddRow:"Tilføj række",tableAddRowAbove:"Tilføj række",tableAddColumnLeft:"Tilføj kolonne",tableAddColumn:"Tilføj kolonne",tableDeleteRow:"Slet række",tableDeleteColumn:"Slet kolonne",tableDestroy:"Slet tabel",error:"Fejl"},de:{table:"Tabelle einfügen",tableAddRow:"Zeile hinzufügen",tableAddRowAbove:"Zeile hinzufügen",tableAddColumnLeft:"Spalte hinzufügen",tableAddColumn:"Spalte hinzufügen",tableDeleteRow:"Zeile löschen",tableDeleteColumn:"Spalte löschen",tableDestroy:"Tabelle löschen",error:"Error"},et:{table:"Sisesta tabel",tableAddRow:"Lisa rida",tableAddRowAbove:"Lisa rida üles",tableAddColumnLeft:"Lisa tulp vasakule",tableAddColumn:"Lisa tulp paremale",tableDeleteRow:"Kustuta rida",tableDeleteColumn:"Kustuta tulp",tableDestroy:"Kustuta tabel",error:"Viga"},fr:{table:"Insérer un tableau",tableAddRow:"Ajouter des lignes",tableAddRowAbove:"Ajouter des lignes",tableAddColumnLeft:"Ajouter des colonnes",tableAddColumn:"Ajouter des colonnes",tableDeleteRow:"Effacer la ligne",tableDeleteColumn:"Effacer la colonne",tableDestroy:"Effacer le tableau",error:"Erreur"},hu:{table:"Táblázat beszúrás",tableAddRow:"Sor hozzáadás",tableAddRowAbove:"Sor beszúrás fönt",tableAddColumnLeft:"Sor beszúrás balra",tableAddColumn:"Sor beszúrás jobbra",tableDeleteRow:"Sor törlés",tableDeleteColumn:"Oszlop törlés",tableDestroy:"Táblázat törlés",error:"Hiba"},id:{table:"Sisipkan tabel",tableAddRow:"Sisipkan baris",tableAddRowAbove:"Sisipkan baris",tableAddColumnLeft:"Sisipkan kolom",tableAddColumn:"Sisipkan kolom",tableDeleteRow:"Hapus baris",tableDeleteColumn:"Hapus kolom",tableDestroy:"Hapus tabel",error:"Galat"},ja:{table:"表の挿入",tableAddRow:"行の追加",tableAddRowAbove:"行の追加",tableAddColumnLeft:"列の追加",tableAddColumn:"列の追加",error:"エラー"},ko:{table:"표 넣기",tableAddRow:"줄 추가",tableAddRowAbove:"줄 추가",tableAddColumnLeft:"칸 추가",tableAddColumn:"칸 추가",tableDeleteRow:"줄 삭제",tableDeleteColumn:"칸 삭제",tableDestroy:"표 지우기",error:"에러"},pt_br:{table:"Inserir tabela",tableAddRow:"Adicionar linha",tableAddRowAbove:"Adicionar linha",tableAddColumnLeft:"Adicionar coluna",tableAddColumn:"Adicionar coluna",tableDeleteRow:"Deletar linha",tableDeleteColumn:"Deletar coluna",tableDestroy:"Deletar tabela",error:"Erro"},ru:{table:"Вставить таблицу",tableAddRow:"Добавить строку",tableAddRowAbove:"Добавить строку",tableAddColumnLeft:"Добавить столбец",tableAddColumn:"Добавить столбец",tableDeleteRow:"Удалить строку",tableDeleteColumn:"Удалить столбец",tableDestroy:"Удалить таблицу",error:"Ошибка"},sk:{table:"Vytvoriť tabuľky",tableAddRow:"Pridať riadok",tableAddRowAbove:"Pridať riadok",tableAddColumnLeft:"Pridať stĺpec",tableAddColumn:"Pridať stĺpec",error:"Chyba"},tr:{table:"Tablo ekle",tableAddRow:"Satır ekle",tableAddRowAbove:"Yukarıya satır ekle",tableAddColumnLeft:"Sola sütun ekle",tableAddColumn:"Sağa sütun ekle",tableDeleteRow:"Satırı sil",tableDeleteColumn:"Sütunu sil",tableDestroy:"Tabloyu sil",error:"Hata"},zh_tw:{table:"插入表格",tableAddRow:"加入行",tableAddRowAbove:"加入行",tableAddColumnLeft:"加入列",tableAddColumn:"加入列",tableDeleteRow:"刪除行",tableDeleteColumn:"刪除列",tableDestroy:"刪除表格",error:"錯誤"},es:{table:"Insertar tabla",tableAddRow:"Agregar fila",tableAddRowAbove:"Agregar fila arriba",tableAddColumnLeft:"Agregar columna a la izquierda",tableAddColumn:"Agregar columna a la derecha",tableDeleteRow:"Borrar fila",tableDeleteColumn:"Borrar columna",tableDestroy:"Borrar tabla",error:"Error"}},plugins:{table:{init:function(l){l.o.plugins.table=e.extend(!0,{},t,l.o.plugins.table||{});var a={fn:function(){l.saveRange();var t="table",a=l.o.prefix+"dropdown",n={class:a+"-"+"table "+a+" "+l.o.prefix+"fixed-top"};n["data-"+a]=t;var b=e("
",n);if(0===l.$box.find("."+a+"-"+t).length?l.$box.append(b.hide()):b=l.$box.find("."+a+"-"+t),b.html(""),l.$box.find("."+l.o.prefix+"table-button").hasClass(l.o.prefix+"active-button"))b.append(l.buildSubBtn("tableAddRowAbove")),b.append(l.buildSubBtn("tableAddRow")),b.append(l.buildSubBtn("tableAddColumnLeft")),b.append(l.buildSubBtn("tableAddColumn")),b.append(l.buildSubBtn("tableDeleteRow")),b.append(l.buildSubBtn("tableDeleteColumn")),b.append(l.buildSubBtn("tableDestroy"));else{var r=e("
').appendTo(row); + } + } + + t.range.deleteContents(); + t.range.insertNode(tabler[0]); + t.$c.trigger('tbwchange'); + }; + + var addRow = { + title: t.lang.tableAddRow, + text: t.lang.tableAddRow, + ico: 'row-below', + + fn: function () { + t.saveRange(); + + var node = t.doc.getSelection().focusNode; + var focusedRow = $(node).closest('tr'); + var table = $(node).closest('table'); + + if(table.length > 0) { + var row = $('
').appendTo(row); + } + // add row to table + focusedRow.after(row); + } + + t.syncCode(); + } + }; + + var addRowAbove = { + title: t.lang.tableAddRowAbove, + text: t.lang.tableAddRowAbove, + ico: 'row-above', + + fn: function () { + t.saveRange(); + + var node = t.doc.getSelection().focusNode; + var focusedRow = $(node).closest('tr'); + var table = $(node).closest('table'); + + if(table.length > 0) { + var row = $('
').appendTo(row); + } + // add row to table + focusedRow.before(row); + } + + t.syncCode(); + } + }; + + var addColumn = { + title: t.lang.tableAddColumn, + text: t.lang.tableAddColumn, + ico: 'col-right', + + fn: function () { + t.saveRange(); + + var node = t.doc.getSelection().focusNode; + var focusedCol = $(node).closest('td'); + var table = $(node).closest('table'); + var focusedColIdx = focusedCol.index(); + + if(table.length > 0) { + $(table).find('tr').each(function() { + $($(this).children()[focusedColIdx]).after('
");e("").appendTo(r);for(var i=0;i").appendTo(r),u=0;u").appendTo(s);r.find("td").on("mouseover",o),r.find("td").on("mousedown",d),b.append(r),b.append(e('
1x1
'))}l.dropdown(t)}},o=function(t){var l=e(t.target).closest("table"),a=this.cellIndex,o=this.parentNode.rowIndex;l.find("td").removeClass("active");for(var d=0;d<=o;d+=1)for(var n=0;n<=a;n+=1)l.find("tr:nth-of-type("+(d+1)+")").find("td:nth-of-type("+(n+1)+")").addClass("active");l.next(".trumbowyg-table-size").html(a+1+"x"+(o+1))},d=function(){l.saveRange();var t=e("
");e("").appendTo(t),l.o.plugins.table.styler&&t.attr("class",l.o.plugins.table.styler);for(var a=this.cellIndex,o=this.parentNode.rowIndex,d=0;d<=o;d+=1)for(var n=e("").appendTo(t),b=0;b<=a;b+=1)e(""),n=0;n").appendTo(d);a.after(d)}l.syncCode()}},b={title:l.lang.tableAddRowAbove,text:l.lang.tableAddRowAbove,ico:"row-above",fn:function(){l.saveRange();var t=l.doc.getSelection().focusNode,a=e(t).closest("tr"),o=e(t).closest("table");if(o.length>0){for(var d=e(""),n=0;n").appendTo(d);a.before(d)}l.syncCode()}},r={title:l.lang.tableAddColumn,text:l.lang.tableAddColumn,ico:"col-right",fn:function(){l.saveRange();var t=l.doc.getSelection().focusNode,a=e(t).closest("td"),o=e(t).closest("table"),d=a.index();o.length>0&&e(o).find("tr").each((function(){e(e(this).children()[d]).after("")})),l.syncCode()}},i={title:l.lang.tableAddColumnLeft,text:l.lang.tableAddColumnLeft,ico:"col-left",fn:function(){l.saveRange();var t=l.doc.getSelection().focusNode,a=e(t).closest("td"),o=e(t).closest("table"),d=a.index();o.length>0&&e(o).find("tr").each((function(){e(e(this).children()[d]).before("")})),l.syncCode()}},s={title:l.lang.tableDestroy,text:l.lang.tableDestroy,ico:"table-delete",fn:function(){l.saveRange();var t=l.doc.getSelection().focusNode;e(t).closest("table").remove(),l.syncCode()}},u={title:l.lang.tableDeleteRow,text:l.lang.tableDeleteRow,ico:"row-delete",fn:function(){l.saveRange();var t=l.doc.getSelection().focusNode;e(t).closest("tr").remove(),l.syncCode()}},f={title:l.lang.tableDeleteColumn,text:l.lang.tableDeleteColumn,ico:"col-delete",fn:function(){l.saveRange();var t=l.doc.getSelection().focusNode,a=e(t).closest("table"),o=e(t).closest("td").index();e(a).find("tr").each((function(){e(this).find("td:eq("+o+")").remove()})),l.syncCode()}};l.addBtnDef("table",a),l.addBtnDef("tableAddRowAbove",b),l.addBtnDef("tableAddRow",n),l.addBtnDef("tableAddColumnLeft",i),l.addBtnDef("tableAddColumn",r),l.addBtnDef("tableDeleteRow",u),l.addBtnDef("tableDeleteColumn",f),l.addBtnDef("tableDestroy",s)}}}})}(jQuery); \ No newline at end of file diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/table/ui/sass/trumbowyg.table.scss b/vasl_templates/webapp/static/trumbowyg/plugins/table/ui/sass/trumbowyg.table.scss new file mode 100644 index 0000000..a7e300c --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/table/ui/sass/trumbowyg.table.scss @@ -0,0 +1,46 @@ +/** + * Trumbowyg v2.25.2 - A lightweight WYSIWYG editor + * Default stylesheet for Trumbowyg editor plugin + * ------------------------ + * @link http://alex-d.github.io/Trumbowyg + * @license MIT + * @author Alexandre Demode (Alex-D) + * Twitter : @AlexandreDemode + * Website : alex-d.fr + */ + +.trumbowyg-editor table { + width: 100%; + + td { + border: 1px dotted #e7eaec; + padding: 8px; + } +} + +.trumbowyg-dropdown-table { + table { + margin: 10px; + display: inline-block; + } + + table td { + display: inline-block; + height: 20px; + width: 20px; + margin: 1px; + padding: 0; + background-color: #fff; + box-shadow: 0 0 0 1px #cecece inset; + + &.active { + background-color: #00b393; + box-shadow: none; + cursor: pointer; + } + } + + .trumbowyg-table-size { + text-align: center; + } +} diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/table/ui/trumbowyg.table.css b/vasl_templates/webapp/static/trumbowyg/plugins/table/ui/trumbowyg.table.css new file mode 100644 index 0000000..e9648c2 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/table/ui/trumbowyg.table.css @@ -0,0 +1,38 @@ +/** + * Trumbowyg v2.25.2 - A lightweight WYSIWYG editor + * Trumbowyg plugin stylesheet + * ------------------------ + * @link http://alex-d.github.io/Trumbowyg + * @license MIT + * @author Alexandre Demode (Alex-D) + * Twitter : @AlexandreDemode + * Website : alex-d.fr + */ + +.trumbowyg-editor table { + width: 100%; } + .trumbowyg-editor table td { + border: 1px dotted #e7eaec; + padding: 8px; } + +.trumbowyg-dropdown-table table { + margin: 10px; + display: inline-block; } + +.trumbowyg-dropdown-table table td { + display: inline-block; + height: 20px; + width: 20px; + margin: 1px; + padding: 0; + background-color: #fff; + -webkit-box-shadow: 0 0 0 1px #cecece inset; + box-shadow: 0 0 0 1px #cecece inset; } + .trumbowyg-dropdown-table table td.active { + background-color: #00b393; + -webkit-box-shadow: none; + box-shadow: none; + cursor: pointer; } + +.trumbowyg-dropdown-table .trumbowyg-table-size { + text-align: center; } diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/table/ui/trumbowyg.table.min.css b/vasl_templates/webapp/static/trumbowyg/plugins/table/ui/trumbowyg.table.min.css new file mode 100644 index 0000000..bcca88b --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/table/ui/trumbowyg.table.min.css @@ -0,0 +1,2 @@ +/** Trumbowyg v2.25.2 - A lightweight WYSIWYG editor - alex-d.github.io/Trumbowyg - License MIT - Author : Alexandre Demode (Alex-D) / alex-d.fr */ +.trumbowyg-editor table{width:100%}.trumbowyg-editor table td{border:1px dotted #e7eaec;padding:8px}.trumbowyg-dropdown-table table{margin:10px;display:inline-block}.trumbowyg-dropdown-table table td{display:inline-block;height:20px;width:20px;margin:1px;padding:0;background-color:#fff;-webkit-box-shadow:0 0 0 1px #cecece inset;box-shadow:0 0 0 1px #cecece inset}.trumbowyg-dropdown-table table td.active{background-color:#00b393;-webkit-box-shadow:none;box-shadow:none;cursor:pointer}.trumbowyg-dropdown-table .trumbowyg-table-size{text-align:center} \ No newline at end of file diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/template/trumbowyg.template.js b/vasl_templates/webapp/static/trumbowyg/plugins/template/trumbowyg.template.js new file mode 100644 index 0000000..a4dc845 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/template/trumbowyg.template.js @@ -0,0 +1,90 @@ +(function ($) { + 'use strict'; + + // Adds the language variables + $.extend(true, $.trumbowyg, { + langs: { + // jshint camelcase:false + en: { + template: 'Template' + }, + by: { + template: 'Шаблон' + }, + da: { + template: 'Skabelon' + }, + de: { + template: 'Vorlage' + }, + et: { + template: 'Mall' + }, + fr: { + template: 'Patron' + }, + hu: { + template: 'Sablon' + }, + ja: { + template: 'テンプレート' + }, + ko: { + template: '서식' + }, + nl: { + template: 'Sjabloon' + }, + pt_br: { + template: 'Modelo' + }, + ru: { + template: 'Шаблон' + }, + tr: { + template: 'Şablon' + }, + zh_tw: { + template: '模板', + }, + // jshint camelcase:true + } + }); + + // Adds the extra button definition + $.extend(true, $.trumbowyg, { + plugins: { + template: { + shouldInit: function (trumbowyg) { + return trumbowyg.o.plugins.hasOwnProperty('templates'); + }, + init: function (trumbowyg) { + trumbowyg.addBtnDef('template', { + dropdown: templateSelector(trumbowyg), + hasIcon: false, + text: trumbowyg.lang.template + }); + } + } + } + }); + + // Creates the template-selector dropdown. + function templateSelector(trumbowyg) { + var available = trumbowyg.o.plugins.templates; + var templates = []; + + $.each(available, function (index, template) { + trumbowyg.addBtnDef('template_' + index, { + fn: function () { + trumbowyg.html(template.html); + }, + hasIcon: false, + title: template.name + }); + templates.push('template_' + index); + }); + + return templates; + } +})(jQuery); diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/template/trumbowyg.template.min.js b/vasl_templates/webapp/static/trumbowyg/plugins/template/trumbowyg.template.min.js new file mode 100644 index 0000000..eba1833 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/template/trumbowyg.template.min.js @@ -0,0 +1 @@ +!function(t){"use strict";function e(e){var a=e.o.plugins.templates,l=[];return t.each(a,(function(t,a){e.addBtnDef("template_"+t,{fn:function(){e.html(a.html)},hasIcon:!1,title:a.name}),l.push("template_"+t)})),l}t.extend(!0,t.trumbowyg,{langs:{en:{template:"Template"},by:{template:"Шаблон"},da:{template:"Skabelon"},de:{template:"Vorlage"},et:{template:"Mall"},fr:{template:"Patron"},hu:{template:"Sablon"},ja:{template:"テンプレート"},ko:{template:"서식"},nl:{template:"Sjabloon"},pt_br:{template:"Modelo"},ru:{template:"Шаблон"},tr:{template:"Şablon"},zh_tw:{template:"模板"}}}),t.extend(!0,t.trumbowyg,{plugins:{template:{shouldInit:function(t){return t.o.plugins.hasOwnProperty("templates")},init:function(t){t.addBtnDef("template",{dropdown:e(t),hasIcon:!1,text:t.lang.template})}}}})}(jQuery); \ No newline at end of file diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/upload/trumbowyg.upload.js b/vasl_templates/webapp/static/trumbowyg/plugins/upload/trumbowyg.upload.js new file mode 100644 index 0000000..276e90c --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/upload/trumbowyg.upload.js @@ -0,0 +1,304 @@ +/* =========================================================== + * trumbowyg.upload.js v1.2 + * Upload plugin for Trumbowyg + * http://alex-d.github.com/Trumbowyg + * =========================================================== + * Author : Alexandre Demode (Alex-D) + * Twitter : @AlexandreDemode + * Website : alex-d.fr + * Mod by : Aleksandr-ru + * Twitter : @Aleksandr_ru + * Website : aleksandr.ru + */ + +(function ($) { + 'use strict'; + + var defaultOptions = { + serverPath: '', + fileFieldName: 'fileToUpload', + data: [], // Additional data for ajax [{name: 'key', value: 'value'}] + headers: {}, // Additional headers + xhrFields: {}, // Additional fields + urlPropertyName: 'file', // How to get url from the json response (for instance 'url' for {url: ....}) + statusPropertyName: 'success', // How to get status from the json response + success: undefined, // Success callback: function (data, trumbowyg, $modal, values) {} + error: undefined, // Error callback: function () {} + imageWidthModalEdit: false // Add ability to edit image width + }; + + function getDeep(object, propertyParts) { + var mainProperty = propertyParts.shift(), + otherProperties = propertyParts; + + if (object !== null) { + if (otherProperties.length === 0) { + return object[mainProperty]; + } + + if (typeof object === 'object') { + return getDeep(object[mainProperty], otherProperties); + } + } + return object; + } + + addXhrProgressEvent(); + + $.extend(true, $.trumbowyg, { + langs: { + // jshint camelcase:false + en: { + upload: 'Upload', + file: 'File', + uploadError: 'Error' + }, + by: { + upload: 'Загрузка', + file: 'Файл', + uploadError: 'Памылка' + }, + cs: { + upload: 'Nahrát obrázek', + file: 'Soubor', + uploadError: 'Chyba' + }, + da: { + upload: 'Upload', + file: 'Fil', + uploadError: 'Fejl' + }, + de: { + upload: 'Hochladen', + file: 'Datei', + uploadError: 'Fehler' + }, + et: { + upload: 'Lae üles', + file: 'Fail', + uploadError: 'Viga' + }, + fr: { + upload: 'Envoi', + file: 'Fichier', + uploadError: 'Erreur' + }, + hu: { + upload: 'Feltöltés', + file: 'Fájl', + uploadError: 'Hiba' + }, + ja: { + upload: 'アップロード', + file: 'ファイル', + uploadError: 'エラー' + }, + ko: { + upload: '그림 올리기', + file: '파일', + uploadError: '에러' + }, + pt_br: { + upload: 'Enviar do local', + file: 'Arquivo', + uploadError: 'Erro' + }, + ru: { + upload: 'Загрузка', + file: 'Файл', + uploadError: 'Ошибка' + }, + sk: { + upload: 'Nahrať', + file: 'Súbor', + uploadError: 'Chyba' + }, + tr: { + upload: 'Yükle', + file: 'Dosya', + uploadError: 'Hata' + }, + zh_cn: { + upload: '上传', + file: '文件', + uploadError: '错误' + }, + zh_tw: { + upload: '上傳', + file: '文件', + uploadError: '錯誤' + }, + }, + // jshint camelcase:true + + plugins: { + upload: { + init: function (trumbowyg) { + trumbowyg.o.plugins.upload = $.extend(true, {}, defaultOptions, trumbowyg.o.plugins.upload || {}); + var btnDef = { + fn: function () { + trumbowyg.saveRange(); + + var file, + prefix = trumbowyg.o.prefix; + + var fields = { + file: { + type: 'file', + required: true, + attributes: { + accept: 'image/*' + } + }, + alt: { + label: 'description', + value: trumbowyg.getRangeText() + } + }; + + if (trumbowyg.o.plugins.upload.imageWidthModalEdit) { + fields.width = { + value: '' + }; + } + + // Prevent multiple submissions while uploading + var isUploading = false; + + var $modal = trumbowyg.openModalInsert( + // Title + trumbowyg.lang.upload, + + // Fields + fields, + + // Callback + function (values) { + if (isUploading) { + return; + } + isUploading = true; + + var data = new FormData(); + data.append(trumbowyg.o.plugins.upload.fileFieldName, file); + + trumbowyg.o.plugins.upload.data.map(function (cur) { + data.append(cur.name, cur.value); + }); + + $.map(values, function (curr, key) { + if (key !== 'file') { + data.append(key, curr); + } + }); + + if ($('.' + prefix + 'progress', $modal).length === 0) { + $('.' + prefix + 'modal-title', $modal) + .after( + $('
', { + 'class': prefix + 'progress' + }).append( + $('
', { + 'class': prefix + 'progress-bar' + }) + ) + ); + } + + $.ajax({ + url: trumbowyg.o.plugins.upload.serverPath, + headers: trumbowyg.o.plugins.upload.headers, + xhrFields: trumbowyg.o.plugins.upload.xhrFields, + type: 'POST', + data: data, + cache: false, + dataType: 'json', + processData: false, + contentType: false, + + progressUpload: function (e) { + $('.' + prefix + 'progress-bar').css('width', Math.round(e.loaded * 100 / e.total) + '%'); + }, + + success: function (data) { + if (trumbowyg.o.plugins.upload.success) { + trumbowyg.o.plugins.upload.success(data, trumbowyg, $modal, values); + } else { + if (!!getDeep(data, trumbowyg.o.plugins.upload.statusPropertyName.split('.'))) { + var url = getDeep(data, trumbowyg.o.plugins.upload.urlPropertyName.split('.')); + trumbowyg.execCmd('insertImage', url, false, true); + var $img = $('img[src="' + url + '"]:not([alt])', trumbowyg.$box); + $img.attr('alt', values.alt); + if (trumbowyg.o.plugins.upload.imageWidthModalEdit && parseInt(values.width) > 0) { + $img.attr({ + width: values.width + }); + } + setTimeout(function () { + trumbowyg.closeModal(); + }, 250); + trumbowyg.$c.trigger('tbwuploadsuccess', [trumbowyg, data, url]); + } else { + trumbowyg.addErrorOnModalField( + $('input[type=file]', $modal), + trumbowyg.lang[data.message] + ); + trumbowyg.$c.trigger('tbwuploaderror', [trumbowyg, data]); + } + } + + isUploading = false; + }, + + error: trumbowyg.o.plugins.upload.error || function () { + trumbowyg.addErrorOnModalField( + $('input[type=file]', $modal), + trumbowyg.lang.uploadError + ); + trumbowyg.$c.trigger('tbwuploaderror', [trumbowyg]); + + isUploading = false; + } + }); + } + ); + + $('input[type=file]').on('change', function (e) { + try { + // If multiple files allowed, we just get the first. + file = e.target.files[0]; + } catch (err) { + // In IE8, multiple files not allowed + file = e.target.value; + } + }); + } + }; + + trumbowyg.addBtnDef('upload', btnDef); + } + } + } + }); + + function addXhrProgressEvent() { + if (!$.trumbowyg.addedXhrProgressEvent) { // Avoid adding progress event multiple times + var originalXhr = $.ajaxSettings.xhr; + $.ajaxSetup({ + xhr: function () { + var that = this, + req = originalXhr(); + + if (req && typeof req.upload === 'object' && that.progressUpload !== undefined) { + req.upload.addEventListener('progress', function (e) { + that.progressUpload(e); + }, false); + } + + return req; + } + }); + $.trumbowyg.addedXhrProgressEvent = true; + } + } +})(jQuery); diff --git a/vasl_templates/webapp/static/trumbowyg/plugins/upload/trumbowyg.upload.min.js b/vasl_templates/webapp/static/trumbowyg/plugins/upload/trumbowyg.upload.min.js new file mode 100644 index 0000000..83bbef6 --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/plugins/upload/trumbowyg.upload.min.js @@ -0,0 +1,13 @@ +/* =========================================================== + * trumbowyg.upload.js v1.2 + * Upload plugin for Trumbowyg + * http://alex-d.github.com/Trumbowyg + * =========================================================== + * Author : Alexandre Demode (Alex-D) + * Twitter : @AlexandreDemode + * Website : alex-d.fr + * Mod by : Aleksandr-ru + * Twitter : @Aleksandr_ru + * Website : aleksandr.ru + */ +!function(r){"use strict";var a={serverPath:"",fileFieldName:"fileToUpload",data:[],headers:{},xhrFields:{},urlPropertyName:"file",statusPropertyName:"success",success:void 0,error:void 0,imageWidthModalEdit:!1};function e(r,a){var o=a.shift(),l=a;if(null!==r){if(0===l.length)return r[o];if("object"==typeof r)return e(r[o],l)}return r}!function(){if(!r.trumbowyg.addedXhrProgressEvent){var a=r.ajaxSettings.xhr;r.ajaxSetup({xhr:function(){var r=this,e=a();return e&&"object"==typeof e.upload&&void 0!==r.progressUpload&&e.upload.addEventListener("progress",(function(a){r.progressUpload(a)}),!1),e}}),r.trumbowyg.addedXhrProgressEvent=!0}}(),r.extend(!0,r.trumbowyg,{langs:{en:{upload:"Upload",file:"File",uploadError:"Error"},by:{upload:"Загрузка",file:"Файл",uploadError:"Памылка"},cs:{upload:"Nahrát obrázek",file:"Soubor",uploadError:"Chyba"},da:{upload:"Upload",file:"Fil",uploadError:"Fejl"},de:{upload:"Hochladen",file:"Datei",uploadError:"Fehler"},et:{upload:"Lae üles",file:"Fail",uploadError:"Viga"},fr:{upload:"Envoi",file:"Fichier",uploadError:"Erreur"},hu:{upload:"Feltöltés",file:"Fájl",uploadError:"Hiba"},ja:{upload:"アップロード",file:"ファイル",uploadError:"エラー"},ko:{upload:"그림 올리기",file:"파일",uploadError:"에러"},pt_br:{upload:"Enviar do local",file:"Arquivo",uploadError:"Erro"},ru:{upload:"Загрузка",file:"Файл",uploadError:"Ошибка"},sk:{upload:"Nahrať",file:"Súbor",uploadError:"Chyba"},tr:{upload:"Yükle",file:"Dosya",uploadError:"Hata"},zh_cn:{upload:"上传",file:"文件",uploadError:"错误"},zh_tw:{upload:"上傳",file:"文件",uploadError:"錯誤"}},plugins:{upload:{init:function(o){o.o.plugins.upload=r.extend(!0,{},a,o.o.plugins.upload||{});var l={fn:function(){o.saveRange();var a,l=o.o.prefix,t={file:{type:"file",required:!0,attributes:{accept:"image/*"}},alt:{label:"description",value:o.getRangeText()}};o.o.plugins.upload.imageWidthModalEdit&&(t.width={value:""});var d=!1,i=o.openModalInsert(o.lang.upload,t,(function(t){if(!d){d=!0;var u=new FormData;u.append(o.o.plugins.upload.fileFieldName,a),o.o.plugins.upload.data.map((function(r){u.append(r.name,r.value)})),r.map(t,(function(r,a){"file"!==a&&u.append(a,r)})),0===r("."+l+"progress",i).length&&r("."+l+"modal-title",i).after(r("
",{class:l+"progress"}).append(r("
",{class:l+"progress-bar"}))),r.ajax({url:o.o.plugins.upload.serverPath,headers:o.o.plugins.upload.headers,xhrFields:o.o.plugins.upload.xhrFields,type:"POST",data:u,cache:!1,dataType:"json",processData:!1,contentType:!1,progressUpload:function(a){r("."+l+"progress-bar").css("width",Math.round(100*a.loaded/a.total)+"%")},success:function(a){if(o.o.plugins.upload.success)o.o.plugins.upload.success(a,o,i,t);else if(e(a,o.o.plugins.upload.statusPropertyName.split("."))){var l=e(a,o.o.plugins.upload.urlPropertyName.split("."));o.execCmd("insertImage",l,!1,!0);var u=r('img[src="'+l+'"]:not([alt])',o.$box);u.attr("alt",t.alt),o.o.plugins.upload.imageWidthModalEdit&&parseInt(t.width)>0&&u.attr({width:t.width}),setTimeout((function(){o.closeModal()}),250),o.$c.trigger("tbwuploadsuccess",[o,a,l])}else o.addErrorOnModalField(r("input[type=file]",i),o.lang[a.message]),o.$c.trigger("tbwuploaderror",[o,a]);d=!1},error:o.o.plugins.upload.error||function(){o.addErrorOnModalField(r("input[type=file]",i),o.lang.uploadError),o.$c.trigger("tbwuploaderror",[o]),d=!1}})}}));r("input[type=file]").on("change",(function(r){try{a=r.target.files[0]}catch(e){a=r.target.value}}))}};o.addBtnDef("upload",l)}}}})}(jQuery); \ No newline at end of file diff --git a/vasl_templates/webapp/static/trumbowyg/trumbowyg.js b/vasl_templates/webapp/static/trumbowyg/trumbowyg.js new file mode 100644 index 0000000..775f7ae --- /dev/null +++ b/vasl_templates/webapp/static/trumbowyg/trumbowyg.js @@ -0,0 +1,2012 @@ +/** + * Trumbowyg v2.25.2 - A lightweight WYSIWYG editor + * Trumbowyg core file + * ------------------------ + * @link http://alex-d.github.io/Trumbowyg + * @license MIT + * @author Alexandre Demode (Alex-D) + * Twitter : @AlexandreDemode + * Website : alex-d.fr + */ + +jQuery.trumbowyg = { + langs: { + en: { + viewHTML: 'View HTML', + + undo: 'Undo', + redo: 'Redo', + + formatting: 'Formatting', + p: 'Paragraph', + blockquote: 'Quote', + code: 'Code', + header: 'Header', + + bold: 'Bold', + italic: 'Italic', + strikethrough: 'Strikethrough', + underline: 'Underline', + + strong: 'Strong', + em: 'Emphasis', + del: 'Deleted', + + superscript: 'Superscript', + subscript: 'Subscript', + + unorderedList: 'Unordered list', + orderedList: 'Ordered list', + + insertImage: 'Insert Image', + link: 'Link', + createLink: 'Insert link', + unlink: 'Remove link', + + justifyLeft: 'Align Left', + justifyCenter: 'Align Center', + justifyRight: 'Align Right', + justifyFull: 'Align Justify', + + horizontalRule: 'Insert horizontal rule', + removeformat: 'Remove format', + + fullscreen: 'Fullscreen', + + close: 'Close', + + submit: 'Confirm', + reset: 'Cancel', + + required: 'Required', + description: 'Description', + title: 'Title', + text: 'Text', + target: 'Target', + width: 'Width' + } + }, + + // Plugins + plugins: {}, + + // SVG Path globally + svgPath: null, + svgAbsoluteUseHref: false, + + hideButtonTexts: null +}; + +// Makes default options read-only +Object.defineProperty(jQuery.trumbowyg, 'defaultOptions', { + value: { + lang: 'en', + + fixedBtnPane: false, + fixedFullWidth: false, + autogrow: false, + autogrowOnEnter: false, + imageWidthModalEdit: false, + hideButtonTexts: null, + + prefix: 'trumbowyg-', + tagClasses: {}, + semantic: true, + semanticKeepAttributes: false, + resetCss: false, + removeformatPasted: false, + tabToIndent: false, + tagsToRemove: [], + tagsToKeep: ['hr', 'img', 'embed', 'iframe', 'input'], + btns: [ + ['viewHTML'], + ['undo', 'redo'], // Only supported in Blink browsers + ['formatting'], + ['strong', 'em', 'del'], + ['superscript', 'subscript'], + ['link'], + ['insertImage'], + ['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'], + ['unorderedList', 'orderedList'], + ['horizontalRule'], + ['removeformat'], + ['fullscreen'] + ], + // For custom button definitions + btnsDef: {}, + changeActiveDropdownIcon: false, + + inlineElementsSelector: 'a,abbr,acronym,b,caption,cite,code,col,dfn,dir,dt,dd,em,font,hr,i,kbd,li,q,span,strikeout,strong,sub,sup,u', + + pasteHandlers: [], + + // imgDblClickHandler: default is defined in constructor + + plugins: {}, + + urlProtocol: false, + minimalLinks: false, + defaultLinkTarget: undefined, + + svgPath: null + }, + writable: false, + enumerable: true, + configurable: false +}); + +(function (navigator, window, document, $) { + 'use strict'; + + var CONFIRM_EVENT = 'tbwconfirm', + CANCEL_EVENT = 'tbwcancel'; + + $.fn.trumbowyg = function (options, params) { + var trumbowygDataName = 'trumbowyg'; + if (options === Object(options) || !options) { + return this.each(function () { + if (!$(this).data(trumbowygDataName)) { + $(this).data(trumbowygDataName, new Trumbowyg(this, options)); + } + }); + } + if (this.length === 1) { + try { + var t = $(this).data(trumbowygDataName); + switch (options) { + // Exec command + case 'execCmd': + return t.execCmd(params.cmd, params.param, params.forceCss, params.skipTrumbowyg); + + // Modal box + case 'openModal': + return t.openModal(params.title, params.content); + case 'closeModal': + return t.closeModal(); + case 'openModalInsert': + return t.openModalInsert(params.title, params.fields, params.callback); + + // Range + case 'saveRange': + return t.saveRange(); + case 'getRange': + return t.range; + case 'getRangeText': + return t.getRangeText(); + case 'restoreRange': + return t.restoreRange(); + + // Enable/disable + case 'enable': + return t.setDisabled(false); + case 'disable': + return t.setDisabled(true); + + // Toggle + case 'toggle': + return t.toggle(); + + // Destroy + case 'destroy': + return t.destroy(); + + // Empty + case 'empty': + return t.empty(); + + // HTML + case 'html': + return t.html(params); + } + } catch (c) { + } + } + + return false; + }; + + // @param: editorElem is the DOM element + var Trumbowyg = function (editorElem, options) { + var t = this, + trumbowygIconsId = 'trumbowyg-icons', + $trumbowyg = $.trumbowyg; + + // Get the document of the element. It use to makes the plugin + // compatible on iframes. + t.doc = editorElem.ownerDocument || document; + + // jQuery object of the editor + t.$ta = $(editorElem); // $ta : Textarea + t.$c = $(editorElem); // $c : creator + + options = options || {}; + + // Localization management + if (options.lang != null || $trumbowyg.langs[options.lang] != null) { + t.lang = $.extend(true, {}, $trumbowyg.langs.en, $trumbowyg.langs[options.lang]); + } else { + t.lang = $trumbowyg.langs.en; + } + + t.hideButtonTexts = $trumbowyg.hideButtonTexts != null ? $trumbowyg.hideButtonTexts : options.hideButtonTexts; + + // SVG path + var svgPathOption = $trumbowyg.svgPath != null ? $trumbowyg.svgPath : options.svgPath; + t.hasSvg = svgPathOption !== false; + + if (svgPathOption !== false && ($trumbowyg.svgAbsoluteUseHref || $('#' + trumbowygIconsId, t.doc).length === 0)) { + if (svgPathOption == null) { + // Hack to get svgPathOption based on trumbowyg.js path + var $scriptElements = $('script[src]'); + $scriptElements.each(function (i, scriptElement) { + var source = scriptElement.src; + var matches = source.match('trumbowyg(\.min)?\.js'); + if (matches != null) { + svgPathOption = source.substring(0, source.indexOf(matches[0])) + 'ui/icons.svg'; + } + }); + } + + // Do not merge with previous if block: svgPathOption can be redefined in it. + // Here we are checking that we find a match + if (svgPathOption == null) { + console.warn('You must define svgPath: https://goo.gl/CfTY9U'); // jshint ignore:line + } else if (!$trumbowyg.svgAbsoluteUseHref) { + var div = t.doc.createElement('div'); + div.id = trumbowygIconsId; + t.doc.body.insertBefore(div, t.doc.body.childNodes[0]); + $.ajax({ + async: true, + type: 'GET', + contentType: 'application/x-www-form-urlencoded; charset=UTF-8', + dataType: 'xml', + crossDomain: true, + url: svgPathOption, + data: null, + beforeSend: null, + complete: null, + success: function (data) { + div.innerHTML = new XMLSerializer().serializeToString(data.documentElement); + } + }); + } + } + + var baseHref = !!t.doc.querySelector('base') ? window.location.href.split(/[?#]/)[0] : ''; + t.svgPath = $trumbowyg.svgAbsoluteUseHref ? svgPathOption : baseHref; + + + /** + * When the button is associated to a empty object + * fn and title attributes are defined from the button key value + * + * For example + * foo: {} + * is equivalent to : + * foo: { + * fn: 'foo', + * title: this.lang.foo + * } + */ + var h = t.lang.header, // Header translation + isBlinkFunction = function () { + return (window.chrome || (window.Intl && Intl.v8BreakIterator)) && 'CSS' in window; + }; + t.btnsDef = { + viewHTML: { + fn: 'toggle', + class: 'trumbowyg-not-disable', + }, + + undo: { + isSupported: isBlinkFunction, + key: 'Z' + }, + redo: { + isSupported: isBlinkFunction, + key: 'Y' + }, + + p: { + fn: 'formatBlock' + }, + blockquote: { + fn: 'formatBlock' + }, + h1: { + fn: 'formatBlock', + title: h + ' 1' + }, + h2: { + fn: 'formatBlock', + title: h + ' 2' + }, + h3: { + fn: 'formatBlock', + title: h + ' 3' + }, + h4: { + fn: 'formatBlock', + title: h + ' 4' + }, + h5: { + fn: 'formatBlock', + title: h + ' 5' + }, + h6: { + fn: 'formatBlock', + title: h + ' 6' + }, + subscript: { + tag: 'sub' + }, + superscript: { + tag: 'sup' + }, + + bold: { + key: 'B', + tag: 'b' + }, + italic: { + key: 'I', + tag: 'i' + }, + underline: { + tag: 'u' + }, + strikethrough: { + tag: 'strike' + }, + + strong: { + fn: 'bold', + key: 'B' + }, + em: { + fn: 'italic', + key: 'I' + }, + del: { + fn: 'strikethrough' + }, + + createLink: { + key: 'K', + tag: 'a' + }, + unlink: {}, + + insertImage: {}, + + justifyLeft: { + tag: 'left', + forceCss: true + }, + justifyCenter: { + tag: 'center', + forceCss: true + }, + justifyRight: { + tag: 'right', + forceCss: true + }, + justifyFull: { + tag: 'justify', + forceCss: true + }, + + unorderedList: { + fn: 'insertUnorderedList', + tag: 'ul' + }, + orderedList: { + fn: 'insertOrderedList', + tag: 'ol' + }, + + horizontalRule: { + fn: 'insertHorizontalRule' + }, + + removeformat: {}, + + fullscreen: { + class: 'trumbowyg-not-disable' + }, + close: { + fn: 'destroy', + class: 'trumbowyg-not-disable' + }, + + // Dropdowns + formatting: { + dropdown: ['p', 'blockquote', 'h1', 'h2', 'h3', 'h4'], + ico: 'p' + }, + link: { + dropdown: ['createLink', 'unlink'] + } + }; + + // Default Options + t.o = $.extend(true, {}, $trumbowyg.defaultOptions, options); + if (!t.o.hasOwnProperty('imgDblClickHandler')) { + t.o.imgDblClickHandler = t.getDefaultImgDblClickHandler(); + } + + t.urlPrefix = t.setupUrlPrefix(); + + t.disabled = t.o.disabled || (editorElem.nodeName === 'TEXTAREA' && editorElem.disabled); + + if (options.btns) { + t.o.btns = options.btns; + } else if (!t.o.semantic) { + t.o.btns[3] = ['bold', 'italic', 'underline', 'strikethrough']; + } + + $.each(t.o.btnsDef, function (btnName, btnDef) { + t.addBtnDef(btnName, btnDef); + }); + + // put this here in the event it would be merged in with options + t.eventNamespace = 'trumbowyg-event'; + + // Keyboard shortcuts are load in this array + t.keys = []; + + // Tag to button dynamically hydrated + t.tagToButton = {}; + t.tagHandlers = []; + + // Admit multiple paste handlers + t.pasteHandlers = [].concat(t.o.pasteHandlers); + + // Check if browser is IE + t.isIE = navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') !== -1; + + // Check if we are on macOs + t.isMac = navigator.platform.toUpperCase().indexOf('MAC') !== -1; + + t.init(); + }; + + Trumbowyg.prototype = { + DEFAULT_SEMANTIC_MAP: { + 'b': 'strong', + 'i': 'em', + 's': 'del', + 'strike': 'del', + 'div': 'p' + }, + + init: function () { + var t = this; + t.height = t.$ta.height(); + + t.initPlugins(); + + try { + // Disable image resize, try-catch for old IE + t.doc.execCommand('enableObjectResizing', false, false); + t.doc.execCommand('defaultParagraphSeparator', false, 'p'); + } catch (e) { + } + + t.buildEditor(); + t.buildBtnPane(); + + t.fixedBtnPaneEvents(); + + t.buildOverlay(); + + setTimeout(function () { + if (t.disabled) { + t.setDisabled(true); + } + t.$c.trigger('tbwinit'); + }); + }, + + addBtnDef: function (btnName, btnDef) { + this.btnsDef[btnName] = $.extend(btnDef, this.btnsDef[btnName] || {}); + }, + + setupUrlPrefix: function () { + var protocol = this.o.urlProtocol; + if (!protocol) { + return; + } + + if (typeof (protocol) !== 'string') { + return 'https://'; + } + return protocol.replace('://', '') + '://'; + }, + + buildEditor: function () { + var t = this, + prefix = t.o.prefix, + html = ''; + + t.$box = $('
', { + class: prefix + 'box ' + prefix + 'editor-visible ' + prefix + t.o.lang + ' trumbowyg' + }); + + // $ta = Textarea + // $ed = Editor + t.isTextarea = t.$ta.is('textarea'); + if (t.isTextarea) { + html = t.$ta.val(); + t.$ed = $('
'); + t.$box + .insertAfter(t.$ta) + .append(t.$ed, t.$ta); + } else { + t.$ed = t.$ta; + html = t.$ed.html(); + + t.$ta = $(' +
+
+
diff --git a/vasl_templates/webapp/templates/index.html b/vasl_templates/webapp/templates/index.html index 918e432..53c520d 100644 --- a/vasl_templates/webapp/templates/index.html +++ b/vasl_templates/webapp/templates/index.html @@ -14,6 +14,12 @@ + + + + + + @@ -36,6 +42,7 @@ + @@ -120,6 +127,16 @@ + + + + + + + + + + + diff --git a/vasl_templates/webapp/templates/lfa.html b/vasl_templates/webapp/templates/lfa.html index 1aca861..3016c32 100644 --- a/vasl_templates/webapp/templates/lfa.html +++ b/vasl_templates/webapp/templates/lfa.html @@ -55,7 +55,7 @@
No animations
").appendTo(n);l.range.deleteContents(),l.range.insertNode(t[0]),l.$c.trigger("tbwchange")},n={title:l.lang.tableAddRow,text:l.lang.tableAddRow,ico:"row-below",fn:function(){l.saveRange();var t=l.doc.getSelection().focusNode,a=e(t).closest("tr"),o=e(t).closest("table");if(o.length>0){for(var d=e("