pod.mak 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <%namespace name="ICON" file="tracim.templates.widgets.icon"/>
  2. <%def name="ICO_URL(icon_size, icon_path)">${h.IconPath(icon_size, icon_path)|n}</%def>
  3. <%def name="ICO(icon_size, icon_path, title='')"><img src="${h.IconPath(icon_size, icon_path)|n}" alt="" title="${title}"/></%def>
  4. <%def name="ICO_TOOLTIP(icon_size, icon_path, title='')"><span rel="tooltip" data-toggle="tooltip" data-placement="bottom" title="${title}">${ICO(icon_size, icon_path, title)}</span></%def>
  5. <%def name="ICO_BADGED(icon_size, icon_path, title='', css_class='badge')"><span class="${css_class}" rel="tooltip" data-toggle="tooltip" data-placement="bottom" title="${title}">${ICO(icon_size, icon_path, title)}</span></%def>
  6. <%def name="ICO_FA_BADGED(fa_class='fa fa-flag', title='', css_style='')"><i style="${css_style}" class="${fa_class}" rel="tooltip" data-toggle="tooltip" data-placement="bottom" title="${title}"></i></%def>
  7. <%def name="FA(fa_class='fa-flag', title='', css_style='', color='auto')"><i style="color: ${color}; ${css_style}" class="fa ${fa_class}" title="${title}"></i></%def>
  8. <%def name="HELP_MODAL_DIALOG(help_page)"><div id="help-modal-dialog-${help_page}" class="modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true"><div class="modal-dialog"><div class="modal-content"></div></div></div></%def>
  9. <%def name="NO_CONTENT_INFO(message)"><div class="alert alert-warning" role="alert">${ICO(32, 'status/dialog-information')} ${message|n}</div></%def>
  10. <%def name="ICO_ACTION(icon_size, icon_path, title, link_url, current_user, required_profile_id)">
  11. % if current_user.profile.id>=required_profile_id:
  12. <a href="${link_url}">${ICO_TOOLTIP(icon_size, icon_path, title)}</a>
  13. % else:
  14. <span class="tracim-less-visible">${ICO(icon_size, icon_path)}</span>
  15. % endif
  16. </%def>
  17. <%def name="MODAL_DIALOG(css_id, modal_size='')">
  18. <div id="${css_id}" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
  19. <div class="modal-dialog ${modal_size}">
  20. <div class="modal-content">
  21. </div>
  22. </div>
  23. </div>
  24. </%def>
  25. <%def name="TINYMCE_INIT_SCRIPT(selector)">
  26. <script>
  27. function base64EncodeAndTinyMceInsert (files) {
  28. for (var i = 0; i < files.length; i++) {
  29. if (files[i].size > 1000000)
  30. files[i].allowed = confirm(files[i].name + " fait plus de 1mo et peut prendre du temps à insérer, voulez-vous continuer ?")
  31. }
  32. for (var i = 0; i < files.length; i++) {
  33. if (files[i].allowed !== false && files[i].type.match('image.*')) {
  34. var img = document.createElement('img')
  35. var fr = new FileReader()
  36. fr.readAsDataURL(files[i])
  37. fr.onloadend = function (e) {
  38. img.src = e.target.result
  39. tinymce.activeEditor.execCommand('mceInsertContent', false, img.outerHTML)
  40. }
  41. }
  42. }
  43. }
  44. // HACK: The tiny mce source code modal contain a textarea, but we
  45. // can't edit it (like it's readonly). The following solution
  46. // solve the bug: https://stackoverflow.com/questions/36952148/tinymce-code-editor-is-readonly-in-jtable-grid
  47. $(document).on('focusin', function(e) {
  48. if ($(e.target).closest(".mce-window").length) {
  49. e.stopImmediatePropagation();
  50. }});
  51. tinymce.init({
  52. menubar:false,
  53. statusbar:true,
  54. branding: false,
  55. plugins: [ "table", "image", "charmap", "fullscreen", "autolink", "colorpicker", "link", "code", "contextmenu", "lists"],
  56. language: globalTracimLang === 'fr' ? 'fr_FR' : globalTracimLang, // tinymce does't accept en_US as language, it is its default value named 'en'
  57. selector:'${selector}',
  58. toolbar: [
  59. "undo redo | bold italic underline strikethrough | link | bullist numlist | outdent indent | table | charmap | styleselect | alignleft aligncenter alignright | fullscreen | customInsertImage | code",
  60. ],
  61. contextmenu: "link",
  62. link_context_toolbar: true,
  63. paste_data_images: true,
  64. table_default_attributes: {
  65. 'class': 'user_content'
  66. },
  67. content_css: '/assets/css/rich-text-area.css',
  68. table_default_styles: {
  69. border: '1px solid #CCC',
  70. borderCollapse: 'collapse',
  71. padding: '20px'
  72. },
  73. table_class_list: [
  74. {title: 'Normal', value: 'user_content'},
  75. {title: 'First row is header', value: 'user_content first_row_headers'},
  76. {title: 'First column is header', value: 'user_content first_column_headers'}
  77. ],
  78. setup: function ($editor) {
  79. //////////////////////////////////////////////
  80. // add custom btn to handle image by selecting them with system explorer
  81. $editor.addButton('customInsertImage', {
  82. icon: 'mce-ico mce-i-image',
  83. title: 'Image',
  84. onclick: function () {
  85. if ($('#hidden_tinymce_fileinput').length > 0) $('#hidden_tinymce_fileinput').remove()
  86. fileTag = document.createElement('input')
  87. fileTag.id = 'hidden_tinymce_fileinput'
  88. fileTag.type = 'file'
  89. $('body').append(fileTag)
  90. $('#hidden_tinymce_fileinput').on('change', function () {
  91. base64EncodeAndTinyMceInsert($(this)[0].files)
  92. })
  93. $('#hidden_tinymce_fileinput').click()
  94. }
  95. })
  96. //////////////////////////////////////////////
  97. // Handle drag & drop image into TinyMce by encoding them in base64 (to avoid uploading them somewhere and keep saving comment in string format)
  98. $editor
  99. .on('drag dragstart dragend dragover dragenter dragleave drop', function (e) {
  100. e.preventDefault()
  101. e.stopPropagation()
  102. })
  103. .on('drop', function(e) {
  104. base64EncodeAndTinyMceInsert(e.dataTransfer.files)
  105. })
  106. }
  107. });
  108. </script>
  109. </%def>
  110. <%def name="FLASH_MSG(css_class='')">
  111. <% flash=tg.flash_obj.render('flash', use_js=False) %>
  112. % if flash:
  113. <div class="" id="flash-message-to-fade-out">
  114. <div id="t-full-app-alert-message-id" class="flashmsg__data ${css_class}">
  115. ${flash|n}
  116. </div>
  117. </div>
  118. ## HACK - D.A. - 2014-10-21
  119. ##
  120. ## The following JS "hack" is intended to make TG2 flash messages compatible with bootstrap alert classes
  121. ## This should disappear as soon as LESS is implemented in the application
  122. ## meaning we'll define a alert-ok style inheriting from alert-info, etc
  123. <script>
  124. $( document ).ready(function() {
  125. $('.alert-ok').removeClass('alert-ok').addClass('alert-info');
  126. $('.alert-error').removeClass('alert-error').addClass('alert-danger');
  127. window.setTimeout(function() {
  128. $("#flash-message-to-fade-out").fadeTo(8000, 0, 'linear', function () {
  129. $(this).hide()
  130. });
  131. }, 2000);
  132. });
  133. </script>
  134. % endif
  135. </%def>