PageRenderTime 25ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/app/assets/javascripts/ckeditor/configs/posts.js.coffee

http://github.com/bborn/communityengine
CoffeeScript | 248 lines | 223 code | 8 blank | 17 comment | 15 complexity | 0b092396ba16a2ecc4c9ea8c649049c5 MD5 | raw file
Possible License(s): MIT, LGPL-2.1
  1. CKEDITOR.editorConfig = (config) ->
  2. ### Filebrowser routes ###
  3. # # The location of an external file browser, that should be launched when "Browse Server" button is pressed.
  4. # config.filebrowserBrowseUrl = '/ckeditor/attachment_files'
  5. # # The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Flash dialog.
  6. # config.filebrowserFlashBrowseUrl = '/ckeditor/attachment_files'
  7. # # The location of a script that handles file uploads in the Flash dialog.
  8. # config.filebrowserFlashUploadUrl = '/ckeditor/attachment_files'
  9. # # The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Link tab of Image dialog.
  10. # config.filebrowserImageBrowseLinkUrl = '/manage_photos'
  11. # The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Image dialog.
  12. config.filebrowserImageBrowseUrl = '/manage_photos'
  13. # The location of a script that handles file uploads in the Image dialog.
  14. config.filebrowserImageUploadUrl = '/manage_photos'
  15. # The location of a script that handles file uploads.
  16. # config.filebrowserUploadUrl = '/ckeditor/attachment_files'
  17. config.allowedContent = true
  18. # Rails CSRF token
  19. config.filebrowserParams = ->
  20. csrf_token = undefined
  21. csrf_param = undefined
  22. meta = undefined
  23. metas = document.getElementsByTagName('meta')
  24. params = new Object
  25. i = 0
  26. while i < metas.length
  27. meta = metas[i]
  28. switch meta.name
  29. when 'csrf-token'
  30. csrf_token = meta.content
  31. when 'csrf-param'
  32. csrf_param = meta.content
  33. else
  34. i++
  35. continue
  36. i++
  37. if csrf_param != undefined and csrf_token != undefined
  38. params[csrf_param] = csrf_token
  39. params
  40. config.addQueryString = (url, params) ->
  41. queryString = []
  42. if !params
  43. return url
  44. else
  45. for i of params
  46. queryString.push i + '=' + encodeURIComponent(params[i])
  47. url + (if url.indexOf('?') != -1 then '&' else '?') + queryString.join('&')
  48. # Integrate Rails CSRF token into file upload dialogs (link, image, attachment and flash)
  49. CKEDITOR.on 'dialogDefinition', (ev) ->
  50. # Take the dialog name and its definition from the event data.
  51. dialogName = ev.data.name
  52. dialogDefinition = ev.data.definition
  53. content = undefined
  54. upload = undefined
  55. if CKEDITOR.tools.indexOf([
  56. 'link'
  57. 'image'
  58. 'attachment'
  59. 'flash'
  60. ], dialogName) > -1
  61. content = dialogDefinition.getContents('Upload') or dialogDefinition.getContents('upload')
  62. upload = if content == null then null else content.get('upload')
  63. if upload and upload.filebrowser and upload.filebrowser['params'] == undefined
  64. upload.filebrowser['params'] = config.filebrowserParams()
  65. upload.action = config.addQueryString(upload.action, upload.filebrowser['params'])
  66. return
  67. # Toolbar groups configuration.
  68. config.toolbar = [
  69. {
  70. name: 'document'
  71. groups: [
  72. 'mode'
  73. 'document'
  74. 'doctools'
  75. ]
  76. items: [ 'Source' ]
  77. }
  78. {
  79. name: 'clipboard'
  80. groups: [
  81. 'clipboard'
  82. 'undo'
  83. ]
  84. items: [
  85. 'Cut'
  86. 'Copy'
  87. 'Paste'
  88. 'PasteText'
  89. 'PasteFromWord'
  90. '-'
  91. 'Undo'
  92. 'Redo'
  93. ]
  94. }
  95. {
  96. name: 'links'
  97. items: [
  98. 'Link'
  99. 'Unlink'
  100. 'Anchor'
  101. ]
  102. }
  103. {
  104. name: 'insert'
  105. items: [
  106. 'Image'
  107. 'Flash'
  108. 'Table'
  109. 'HorizontalRule'
  110. 'SpecialChar'
  111. ]
  112. }
  113. {
  114. name: 'paragraph'
  115. groups: [
  116. 'list'
  117. 'indent'
  118. 'blocks'
  119. 'align'
  120. 'bidi'
  121. ]
  122. items: [
  123. 'NumberedList'
  124. 'BulletedList'
  125. '-'
  126. 'Outdent'
  127. 'Indent'
  128. '-'
  129. 'Blockquote'
  130. 'CreateDiv'
  131. '-'
  132. 'JustifyLeft'
  133. 'JustifyCenter'
  134. 'JustifyRight'
  135. 'JustifyBlock'
  136. ]
  137. }
  138. '/'
  139. {
  140. name: 'styles'
  141. items: [
  142. 'Styles'
  143. 'Format'
  144. 'Font'
  145. 'FontSize'
  146. ]
  147. }
  148. {
  149. name: 'colors'
  150. items: [
  151. 'TextColor'
  152. 'BGColor'
  153. ]
  154. }
  155. {
  156. name: 'basicstyles'
  157. groups: [
  158. 'basicstyles'
  159. 'cleanup'
  160. ]
  161. items: [
  162. 'Bold'
  163. 'Italic'
  164. 'Underline'
  165. 'Strike'
  166. 'Subscript'
  167. 'Superscript'
  168. '-'
  169. 'RemoveFormat'
  170. ]
  171. }
  172. ]
  173. config.toolbar_mini = [
  174. {
  175. name: 'paragraph'
  176. groups: [
  177. 'list'
  178. 'indent'
  179. 'blocks'
  180. 'align'
  181. 'bidi'
  182. ]
  183. items: [
  184. 'NumberedList'
  185. 'BulletedList'
  186. '-'
  187. 'Outdent'
  188. 'Indent'
  189. '-'
  190. 'Blockquote'
  191. 'CreateDiv'
  192. '-'
  193. 'JustifyLeft'
  194. 'JustifyCenter'
  195. 'JustifyRight'
  196. 'JustifyBlock'
  197. ]
  198. }
  199. {
  200. name: 'styles'
  201. items: [
  202. 'Font'
  203. 'FontSize'
  204. ]
  205. }
  206. {
  207. name: 'colors'
  208. items: [
  209. 'TextColor'
  210. 'BGColor'
  211. ]
  212. }
  213. {
  214. name: 'basicstyles'
  215. groups: [
  216. 'basicstyles'
  217. 'cleanup'
  218. ]
  219. items: [
  220. 'Bold'
  221. 'Italic'
  222. 'Underline'
  223. 'Strike'
  224. 'Subscript'
  225. 'Superscript'
  226. '-'
  227. 'RemoveFormat'
  228. ]
  229. }
  230. {
  231. name: 'insert'
  232. items: [
  233. 'Image'
  234. 'Table'
  235. 'HorizontalRule'
  236. 'SpecialChar'
  237. ]
  238. }
  239. ]
  240. return