You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

textile.js 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * This file is part of DotClear.
  3. * Copyright (c) 2005 Nicolas Martin & Olivier Meunier and contributors. All
  4. * rights reserved.
  5. *
  6. * DotClear is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * DotClear is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with DotClear; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. *
  20. * ***** END LICENSE BLOCK *****
  21. */
  22. /* Modified by JP LANG for textile formatting */
  23. // strong
  24. jsToolBar.prototype.elements.strong = {
  25. type: 'button',
  26. title: 'Strong',
  27. fn: {
  28. wiki: function() { this.singleTag('*') }
  29. }
  30. }
  31. // em
  32. jsToolBar.prototype.elements.em = {
  33. type: 'button',
  34. title: 'Italic',
  35. fn: {
  36. wiki: function() { this.singleTag("_") }
  37. }
  38. }
  39. // ins
  40. jsToolBar.prototype.elements.ins = {
  41. type: 'button',
  42. title: 'Underline',
  43. fn: {
  44. wiki: function() { this.singleTag('+') }
  45. }
  46. }
  47. // del
  48. jsToolBar.prototype.elements.del = {
  49. type: 'button',
  50. title: 'Deleted',
  51. fn: {
  52. wiki: function() { this.singleTag('-') }
  53. }
  54. }
  55. // code
  56. jsToolBar.prototype.elements.code = {
  57. type: 'button',
  58. title: 'Code',
  59. fn: {
  60. wiki: function() { this.singleTag('@') }
  61. }
  62. }
  63. // spacer
  64. jsToolBar.prototype.elements.space1 = {type: 'space'}
  65. // headings
  66. jsToolBar.prototype.elements.h1 = {
  67. type: 'button',
  68. title: 'Heading 1',
  69. fn: {
  70. wiki: function() {
  71. this.encloseLineSelection('h1. ', '',function(str) {
  72. str = str.replace(/^h\d+\.\s+/, '')
  73. return str;
  74. });
  75. }
  76. }
  77. }
  78. jsToolBar.prototype.elements.h2 = {
  79. type: 'button',
  80. title: 'Heading 2',
  81. fn: {
  82. wiki: function() {
  83. this.encloseLineSelection('h2. ', '',function(str) {
  84. str = str.replace(/^h\d+\.\s+/, '')
  85. return str;
  86. });
  87. }
  88. }
  89. }
  90. jsToolBar.prototype.elements.h3 = {
  91. type: 'button',
  92. title: 'Heading 3',
  93. fn: {
  94. wiki: function() {
  95. this.encloseLineSelection('h3. ', '',function(str) {
  96. str = str.replace(/^h\d+\.\s+/, '')
  97. return str;
  98. });
  99. }
  100. }
  101. }
  102. // spacer
  103. jsToolBar.prototype.elements.space2 = {type: 'space'}
  104. // ul
  105. jsToolBar.prototype.elements.ul = {
  106. type: 'button',
  107. title: 'Unordered list',
  108. fn: {
  109. wiki: function() {
  110. this.encloseLineSelection('','',function(str) {
  111. str = str.replace(/\r/g,'');
  112. return str.replace(/(\n|^)[#-]?\s*/g,"$1* ");
  113. });
  114. }
  115. }
  116. }
  117. // ol
  118. jsToolBar.prototype.elements.ol = {
  119. type: 'button',
  120. title: 'Ordered list',
  121. fn: {
  122. wiki: function() {
  123. this.encloseLineSelection('','',function(str) {
  124. str = str.replace(/\r/g,'');
  125. return str.replace(/(\n|^)[*-]?\s*/g,"$1# ");
  126. });
  127. }
  128. }
  129. }
  130. // spacer
  131. jsToolBar.prototype.elements.space3 = {type: 'space'}
  132. // bq
  133. jsToolBar.prototype.elements.bq = {
  134. type: 'button',
  135. title: 'Quote',
  136. fn: {
  137. wiki: function() {
  138. this.encloseLineSelection('','',function(str) {
  139. str = str.replace(/\r/g,'');
  140. return str.replace(/(\n|^) *([^\n]*)/g,"$1> $2");
  141. });
  142. }
  143. }
  144. }
  145. // unbq
  146. jsToolBar.prototype.elements.unbq = {
  147. type: 'button',
  148. title: 'Unquote',
  149. fn: {
  150. wiki: function() {
  151. this.encloseLineSelection('','',function(str) {
  152. str = str.replace(/\r/g,'');
  153. return str.replace(/(\n|^) *[>]? *([^\n]*)/g,"$1$2");
  154. });
  155. }
  156. }
  157. }
  158. // pre
  159. jsToolBar.prototype.elements.pre = {
  160. type: 'button',
  161. title: 'Preformatted text',
  162. fn: {
  163. wiki: function() { this.encloseLineSelection('<pre>\n', '\n</pre>') }
  164. }
  165. }
  166. // spacer
  167. jsToolBar.prototype.elements.space4 = {type: 'space'}
  168. // wiki page
  169. jsToolBar.prototype.elements.link = {
  170. type: 'button',
  171. title: 'Wiki link',
  172. fn: {
  173. wiki: function() { this.encloseSelection("[[", "]]") }
  174. }
  175. }
  176. // image
  177. jsToolBar.prototype.elements.img = {
  178. type: 'button',
  179. title: 'Image',
  180. fn: {
  181. wiki: function() { this.encloseSelection("!", "!") }
  182. }
  183. }
  184. // spacer
  185. jsToolBar.prototype.elements.space5 = {type: 'space'}
  186. // help
  187. jsToolBar.prototype.elements.help = {
  188. type: 'button',
  189. title: 'Help',
  190. fn: {
  191. wiki: function() { window.open(this.help_link, '', 'resizable=yes, location=no, width=300, height=640, menubar=no, status=no, scrollbars=yes') }
  192. }
  193. }