liquid_feedback_frontend
view env/ui/field/wysihtml.lua @ 1438:d55f506f032b
Order unit list in member admin page
author | bsw |
---|---|
date | Thu Oct 18 11:19:05 2018 +0200 (2018-10-18) |
parents | 32cc544d5a5b |
children | 56209dc74a9c |
line source
1 function ui.field.wysihtml(args)
3 local toolbar = {
4 { command = "bold", title ="CTRL+B", icon = "format_bold" },
5 { command = "italic", title ="CTRL+I", icon = "format_italic" },
6 { command = "createLink", icon = "insert_link" },
7 { command = "removeLink", icon = "insert_link", crossed = "\\" },
8 { command = "formatBlock", command_value = "h1", icon = "title", head_level = "1" },
9 { command = "formatBlock", command_value = "h2", icon = "title", head_level = "2" },
10 { command = "formatBlock", command_value = "h3", icon = "title", head_level = "3" },
11 { command = "formatBlock", command_blank = "true", icon = "format_clear" },
12 { command = "insertBlockQuote", icon = "format_quote" },
13 { command = "insertUnorderedList", icon = "format_list_bulleted" },
14 { command = "insertOrderedList", icon = "format_list_numbered" },
15 { command = "outdentList", icon = "format_indent_decrease" },
16 { command = "indentList", icon = "format_indent_increase" },
17 -- { command = "alignLeftStyle", icon = "format_align_left" },
18 -- { command = "alignRightStyle", icon = "format_align_right" },
19 -- { command = "alignCenterStyle", icon = "format_align_center" },
20 { command = "undo", icon = "undo" },
21 { command = "redo", icon = "redo" }
22 }
24 slot.put([[
25 <style>
26 #wysihtml-html-button {
27 padding: 2px;
28 vertical-align: bottom;
29 }
30 #wysihtml-html-button.wysihtml-action-active {
31 color: #fff;
32 background: #000;
33 }
34 </style>
35 ]])
37 ui.container{ attr = { id = "toolbar", class = "toolbar", style = "display: none;" }, content = function()
38 for i, t in ipairs(toolbar) do
39 ui.tag{ tag = "a", attr = { ["data-wysihtml-command"] = t.command, ["data-wysihtml-command-value"] = t.command_value, ["data-wysihtml-command-blank-value"] = t.command_blank, title = t.shortcut }, content = function()
40 ui.tag{ tag = "i", attr = { class = "material-icons" }, content = t.icon }
41 if t.crossed then
42 ui.tag{ attr = { class = "crossed" }, content = t.crossed }
43 end
44 if t.head_level then
45 ui.tag{ attr = { class = "head_level" }, content = t.head_level }
46 end
47 end }
48 end
49 slot.put([[
50 <div data-wysihtml-dialog="createLink" style="display: none;">
51 <label>
52 Link:
53 <input data-wysihtml-dialog-field="href" value="http://">
54 </label>
55 <a data-wysihtml-dialog-action="save">OK</a> <a data-wysihtml-dialog-action="cancel">Cancel</a>
56 </div>
57 ]])
58 slot.put([[ <a id="wysihtml-html-button" data-wysihtml-action="change_view">]] .. _"expert editor (HTML)" .. [[</a> ]])
59 end }
61 ui.field.text(args)
63 ui.tag{ tag = "script", attr = { src = request.get_absolute_baseurl() .. "static/wysihtml/wysihtml.js" }, content = "" }
64 ui.tag{ tag = "script", attr = { src = request.get_absolute_baseurl() .. "static/wysihtml/wysihtml.all-commands.js" }, content = "" }
65 ui.tag{ tag = "script", attr = { src = request.get_absolute_baseurl() .. "static/wysihtml/wysihtml.toolbar.js" }, content = "" }
66 ui.tag{ tag = "script", attr = { src = request.get_absolute_baseurl() .. "static/wysihtml/wysihtml_liquidfeedback_rules.js" }, content = "" }
67 ui.script{ script = [[
68 function initEditor() {
69 var editor = new wysihtml.Editor("]] .. args.attr.id .. [[", {
70 toolbar: "toolbar",
71 parserRules: wysihtmlParserRules,
72 useLineBreaks: true
73 });
74 }
75 if(window.addEventListener){
76 window.addEventListener('load', initEditor, false);
77 } else {
78 window.attachEvent('onload', initEditor);
79 }
80 ]] }
82 end