index.html 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset='utf-8' />
  5. <meta name="viewport" content="width=device-width, user-scalable=no">
  6. <title>Tracim</title>
  7. <link rel='shortcut icon' href='favicon.ico'>
  8. <link rel="stylesheet" type="text/css" href="/font/font-awesome-4.7.0/css/font-awesome.css">
  9. <link href="https://fonts.googleapis.com/css?family=Quicksand:300,400,500,700" rel="stylesheet">
  10. <!--
  11. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
  12. -->
  13. <link rel="stylesheet" type="text/css" href="/asset/hamburger/hamburgers.min.css">
  14. <link rel="stylesheet" type="text/css" href="/dev/bootstrap-4.0.0-beta.css">
  15. </head>
  16. <body>
  17. <div id='content'></div>
  18. <script src='/tracim.vendor.bundle.js'></script>
  19. <script src='/tracim.app.entry.js'></script>
  20. <!--
  21. <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
  22. <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
  23. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
  24. -->
  25. <script src='/app/pageHtml.app.js'></script>
  26. <script src='/app/thread.app.js'></script>
  27. <script src="/dev/jquery-3.2.1.js"></script>
  28. <script src="/dev/popper-1.12.3.js"></script>
  29. <script src="/dev/bootstrap-4.0.0-beta.2.js"></script>
  30. <script type="text/javascript" src="/asset/tinymce/jquery.tinymce.min.js"></script>
  31. <script type="text/javascript" src="/asset/tinymce/tinymce.min.js"></script>
  32. <script type='text/javascript'>
  33. let prevSelectedApp = {name: ''} // default value
  34. GLOBAL_renderApp = app => {
  35. const selectedApp = (() => {
  36. switch (app.config.name) {
  37. case 'PageHtml':
  38. return appPageHtml
  39. case 'Thread':
  40. return appThread
  41. }
  42. })()
  43. if (selectedApp.isRendered) {
  44. GLOBAL_dispatchEvent(`${app.config.name}_showApp`, app)
  45. } else {
  46. selectedApp.renderApp(app)
  47. selectedApp.isRendered = true
  48. prevSelectedApp.isRendered = false
  49. prevSelectedApp = selectedApp
  50. }
  51. }
  52. GLOBAL_dispatchEvent = (type, data) => {
  53. var event = new CustomEvent('appCustomEvent', {detail: {type, data}})
  54. document.dispatchEvent(event)
  55. }
  56. GLOBAL_hideApp = appName => {
  57. switch (appName) {
  58. case 'PageHtml':
  59. GLOBAL_dispatchEvent('PageHtml_hideApp', {}); break
  60. case 'Thread':
  61. GLOBAL_dispatchEvent('Thread_hideApp', {}); break
  62. }
  63. }
  64. </script>
  65. <script type='text/javascript'>
  66. $(document).ready(function () {
  67. wysiwyg = function () {
  68. function base64EncodeAndTinyMceInsert (files) {
  69. for (var i = 0; i < files.length; i++) {
  70. if (files[i].size > 1000000)
  71. files[i].allowed = confirm(files[i].name + " fait plus de 1mo et peut prendre du temps à insérer, voulez-vous continuer ?")
  72. }
  73. for (var i = 0; i < files.length; i++) {
  74. if (files[i].allowed !== false && files[i].type.match('image.*')) {
  75. var img = document.createElement('img')
  76. var fr = new FileReader()
  77. fr.readAsDataURL(files[i])
  78. fr.onloadend = function (e) {
  79. img.src = e.target.result
  80. tinymce.activeEditor.execCommand('mceInsertContent', false, img.outerHTML)
  81. }
  82. }
  83. }
  84. }
  85. // HACK: The tiny mce source code modal contain a textarea, but we
  86. // can't edit it (like it's readonly). The following solution
  87. // solve the bug: https://stackoverflow.com/questions/36952148/tinymce-code-editor-is-readonly-in-jtable-grid
  88. $(document).on('focusin', function(e) {
  89. if ($(e.target).closest(".mce-window").length) {
  90. e.stopImmediatePropagation();
  91. }
  92. });
  93. tinymce.init({
  94. selector: 'textarea',
  95. height: 130,
  96. // width: 530,
  97. menubar: false,
  98. resize: false,
  99. plugins: [
  100. 'advlist autolink lists link image charmap print preview anchor textcolor',
  101. 'searchreplace visualblocks code fullscreen',
  102. 'insertdatetime media table contextmenu paste code help'
  103. ],
  104. toolbar: 'insert | formatselect | bold italic underline strikethrough forecolor backcolor | link | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | table | code ',
  105. content_css: [
  106. '//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
  107. '//www.tinymce.com/css/codepen.min.css'
  108. ],
  109. setup: function ($editor) {
  110. //////////////////////////////////////////////
  111. // add custom btn to handle image by selecting them with system explorer
  112. $editor.addButton('customInsertImage', {
  113. icon: 'mce-ico mce-i-image',
  114. title: 'Image',
  115. onclick: function () {
  116. if ($('#hidden_tinymce_fileinput').length > 0) $('#hidden_tinymce_fileinput').remove()
  117. fileTag = document.createElement('input')
  118. fileTag.id = 'hidden_tinymce_fileinput'
  119. fileTag.type = 'file'
  120. $('body').append(fileTag)
  121. $('#hidden_tinymce_fileinput').on('change', function () {
  122. base64EncodeAndTinyMceInsert($(this)[0].files)
  123. })
  124. $('#hidden_tinymce_fileinput').click()
  125. }
  126. })
  127. //////////////////////////////////////////////
  128. // Handle drag & drop image into TinyMce by encoding them in base64 (to avoid uploading them somewhere and keep saving comment in string format)
  129. $editor
  130. .on('drag dragstart dragend dragover dragenter dragleave drop', function (e) {
  131. e.preventDefault()
  132. e.stopPropagation()
  133. })
  134. .on('drop', function(e) {
  135. base64EncodeAndTinyMceInsert(e.dataTransfer.files)
  136. })
  137. }
  138. });
  139. }
  140. wysiwyg()
  141. })
  142. </script>
  143. </body>
  144. </html>