index.html 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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='/app/file.app.js'></script>
  28. <script src="/dev/jquery-3.2.1.js"></script>
  29. <script src="/dev/popper-1.12.3.js"></script>
  30. <script src="/dev/bootstrap-4.0.0-beta.2.js"></script>
  31. <script type="text/javascript" src="/asset/tinymce/jquery.tinymce.min.js"></script>
  32. <script type="text/javascript" src="/asset/tinymce/tinymce.min.js"></script>
  33. <script type='text/javascript'>
  34. let prevSelectedApp = {name: ''} // default value
  35. getSelectedApp = name => {
  36. switch (name) {
  37. case 'PageHtml':
  38. return appPageHtml
  39. case 'Thread':
  40. return appThread
  41. case 'File':
  42. return appFile
  43. }
  44. }
  45. GLOBAL_renderApp = app => {
  46. console.log('GLOBAL_renderApp', app)
  47. const selectedApp = getSelectedApp(app.config.name)
  48. if (selectedApp.isRendered) {
  49. GLOBAL_dispatchEvent({type: `${app.config.name}_showApp`, data: app})
  50. } else {
  51. selectedApp.renderApp(app)
  52. selectedApp.isRendered = true
  53. prevSelectedApp.isRendered = false
  54. prevSelectedApp = selectedApp
  55. }
  56. }
  57. GLOBAL_renderCreateContentApp = app => {
  58. console.log('GLOBAL_renderCreateContentApp', app)
  59. getSelectedApp(app.config.name).renderPopupCreation(app)
  60. }
  61. GLOBAL_dispatchEvent = ({ type, data }) => {
  62. console.log('GLOBAL_dispatchEvent', type, data)
  63. const event = new CustomEvent('appCustomEvent', { detail: { type, data } })
  64. document.dispatchEvent(event)
  65. }
  66. GLOBAL_eventReducer = ({ detail: { type, data } }) => {
  67. console.log('GLOBAL_eventReducer', type, data)
  68. switch (type) {
  69. case 'hide_popupCreateContent':
  70. getSelectedApp(data.name).hideApp('popupCreateContentContainer')
  71. break
  72. }
  73. }
  74. document.addEventListener('appCustomEvent', GLOBAL_eventReducer)
  75. </script>
  76. <script type='text/javascript'>
  77. $(document).ready(function () {
  78. wysiwyg = function () {
  79. function base64EncodeAndTinyMceInsert (files) {
  80. for (var i = 0; i < files.length; i++) {
  81. if (files[i].size > 1000000)
  82. files[i].allowed = confirm(files[i].name + " fait plus de 1mo et peut prendre du temps à insérer, voulez-vous continuer ?")
  83. }
  84. for (var i = 0; i < files.length; i++) {
  85. if (files[i].allowed !== false && files[i].type.match('image.*')) {
  86. var img = document.createElement('img')
  87. var fr = new FileReader()
  88. fr.readAsDataURL(files[i])
  89. fr.onloadend = function (e) {
  90. img.src = e.target.result
  91. tinymce.activeEditor.execCommand('mceInsertContent', false, img.outerHTML)
  92. }
  93. }
  94. }
  95. }
  96. // HACK: The tiny mce source code modal contain a textarea, but we
  97. // can't edit it (like it's readonly). The following solution
  98. // solve the bug: https://stackoverflow.com/questions/36952148/tinymce-code-editor-is-readonly-in-jtable-grid
  99. $(document).on('focusin', function(e) {
  100. if ($(e.target).closest(".mce-window").length) {
  101. e.stopImmediatePropagation();
  102. }
  103. });
  104. tinymce.init({
  105. selector: 'textarea',
  106. height: 130,
  107. // width: 530,
  108. menubar: false,
  109. resize: false,
  110. plugins: [
  111. 'advlist autolink lists link image charmap print preview anchor textcolor',
  112. 'searchreplace visualblocks code fullscreen',
  113. 'insertdatetime media table contextmenu paste code help'
  114. ],
  115. toolbar: 'insert | formatselect | bold italic underline strikethrough forecolor backcolor | link | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | table | code ',
  116. content_css: [
  117. '//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
  118. '//www.tinymce.com/css/codepen.min.css'
  119. ],
  120. setup: function ($editor) {
  121. //////////////////////////////////////////////
  122. // add custom btn to handle image by selecting them with system explorer
  123. $editor.addButton('customInsertImage', {
  124. icon: 'mce-ico mce-i-image',
  125. title: 'Image',
  126. onclick: function () {
  127. if ($('#hidden_tinymce_fileinput').length > 0) $('#hidden_tinymce_fileinput').remove()
  128. fileTag = document.createElement('input')
  129. fileTag.id = 'hidden_tinymce_fileinput'
  130. fileTag.type = 'file'
  131. $('body').append(fileTag)
  132. $('#hidden_tinymce_fileinput').on('change', function () {
  133. base64EncodeAndTinyMceInsert($(this)[0].files)
  134. })
  135. $('#hidden_tinymce_fileinput').click()
  136. }
  137. })
  138. //////////////////////////////////////////////
  139. // Handle drag & drop image into TinyMce by encoding them in base64 (to avoid uploading them somewhere and keep saving comment in string format)
  140. $editor
  141. .on('drag dragstart dragend dragover dragenter dragleave drop', function (e) {
  142. e.preventDefault()
  143. e.stopPropagation()
  144. })
  145. .on('drop', function(e) {
  146. base64EncodeAndTinyMceInsert(e.dataTransfer.files)
  147. })
  148. }
  149. });
  150. }
  151. wysiwyg()
  152. })
  153. </script>
  154. </body>
  155. </html>