index.html 7.1KB

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