diff options
Diffstat (limited to 'src/application/views/template_end.php')
| -rw-r--r-- | src/application/views/template_end.php | 57 | 
1 files changed, 57 insertions, 0 deletions
| diff --git a/src/application/views/template_end.php b/src/application/views/template_end.php index 9207170..b162def 100644 --- a/src/application/views/template_end.php +++ b/src/application/views/template_end.php @@ -43,6 +43,63 @@  </div>  </footer> +<script type="text/javascript"> +    $(function() { +        function insertAroundSelection(textarea, before, after) { +            var start = textarea.selectionStart; +            var end = textarea.selectionEnd; +            var text = textarea.value; +            var pre = text.substring(0, start); +            var inner = text.substring(start, end); +            var post = text.substring(end); +            start += before.length; +            end += before.length; +            text = pre + before + inner + after + post; +            textarea.value = text; +            textarea.focus(); +            textarea.selectionStart = start; +            textarea.selectionEnd = end; +        } + +        function getTextarea(btn) { +            return $($(btn).attr("data-area"))[0]; +        } + +        var commands = { +            bold: function(textarea) { +                insertAroundSelection(textarea, "[b]", "[/b]"); +            }, +            italic: function(textarea) { +                insertAroundSelection(textarea, "[i]", "[/i]"); +            }, +            underline: function(textarea) { +                insertAroundSelection(textarea, "[u]", "[/u]"); +            }, +            strikethrough: function(textarea) { +                insertAroundSelection(textarea, "[s]", "[/s]"); +            }, +            sup: function(textarea) { +                insertAroundSelection(textarea, "[^]", "[/^]"); +            }, +            sub: function(textarea) { +                insertAroundSelection(textarea, "[_]", "[/_]"); +            }, +            quote: function(textarea) { +                insertAroundSelection(textarea, "> ", ""); +            }, +            spoiler: function(textarea) { +                insertAroundSelection(textarea, "[spoiler]", "[/spoiler]"); +            } +        } + +        $("button[data-editor-command]").attr("data-toggle", "tooltip").attr("data-placement", "bottom").click(function() { +            var command = $(this).attr("data-editor-command"); +            var textarea = getTextarea(this); +            commands[command](textarea); +        }).tooltip(); +    }); +</script> +  <script>  $(function() {      var _messages = <?= json_encode([ |