summaryrefslogtreecommitdiffstats
path: root/public
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-10-27 11:08:29 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-10-27 11:08:29 +0000
commita3b9a5aa5fe344cf33a47ccbf1d26a95fbe4e255 (patch)
tree6b19387c81e2d865a57cf3357340deffdbc5e858 /public
parent9b624fd1d6f66bbe60d738522d9fc5fd547ef3af (diff)
downloadredmine-a3b9a5aa5fe344cf33a47ccbf1d26a95fbe4e255.tar.gz
redmine-a3b9a5aa5fe344cf33a47ccbf1d26a95fbe4e255.zip
Makes wiki text formatter pluggable.
Original patch #2025 by Yuki Sonoda slightly edited. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@1955 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'public')
-rw-r--r--public/javascripts/jstoolbar/jstoolbar.js179
-rw-r--r--public/javascripts/jstoolbar/textile.js200
2 files changed, 200 insertions, 179 deletions
diff --git a/public/javascripts/jstoolbar/jstoolbar.js b/public/javascripts/jstoolbar/jstoolbar.js
index 64c460217..66669ceee 100644
--- a/public/javascripts/jstoolbar/jstoolbar.js
+++ b/public/javascripts/jstoolbar/jstoolbar.js
@@ -378,182 +378,3 @@ jsToolBar.prototype.resizeDragStop = function(event) {
document.removeEventListener('mousemove', this.dragMoveHdlr, false);
document.removeEventListener('mouseup', this.dragStopHdlr, false);
};
-
-// Elements definition ------------------------------------
-
-// strong
-jsToolBar.prototype.elements.strong = {
- type: 'button',
- title: 'Strong',
- fn: {
- wiki: function() { this.singleTag('*') }
- }
-}
-
-// em
-jsToolBar.prototype.elements.em = {
- type: 'button',
- title: 'Italic',
- fn: {
- wiki: function() { this.singleTag("_") }
- }
-}
-
-// ins
-jsToolBar.prototype.elements.ins = {
- type: 'button',
- title: 'Underline',
- fn: {
- wiki: function() { this.singleTag('+') }
- }
-}
-
-// del
-jsToolBar.prototype.elements.del = {
- type: 'button',
- title: 'Deleted',
- fn: {
- wiki: function() { this.singleTag('-') }
- }
-}
-
-// code
-jsToolBar.prototype.elements.code = {
- type: 'button',
- title: 'Code',
- fn: {
- wiki: function() { this.singleTag('@') }
- }
-}
-
-// spacer
-jsToolBar.prototype.elements.space1 = {type: 'space'}
-
-// headings
-jsToolBar.prototype.elements.h1 = {
- type: 'button',
- title: 'Heading 1',
- fn: {
- wiki: function() {
- this.encloseLineSelection('h1. ', '',function(str) {
- str = str.replace(/^h\d+\.\s+/, '')
- return str;
- });
- }
- }
-}
-jsToolBar.prototype.elements.h2 = {
- type: 'button',
- title: 'Heading 2',
- fn: {
- wiki: function() {
- this.encloseLineSelection('h2. ', '',function(str) {
- str = str.replace(/^h\d+\.\s+/, '')
- return str;
- });
- }
- }
-}
-jsToolBar.prototype.elements.h3 = {
- type: 'button',
- title: 'Heading 3',
- fn: {
- wiki: function() {
- this.encloseLineSelection('h3. ', '',function(str) {
- str = str.replace(/^h\d+\.\s+/, '')
- return str;
- });
- }
- }
-}
-
-// spacer
-jsToolBar.prototype.elements.space2 = {type: 'space'}
-
-// ul
-jsToolBar.prototype.elements.ul = {
- type: 'button',
- title: 'Unordered list',
- fn: {
- wiki: function() {
- this.encloseLineSelection('','',function(str) {
- str = str.replace(/\r/g,'');
- return str.replace(/(\n|^)[#-]?\s*/g,"$1* ");
- });
- }
- }
-}
-
-// ol
-jsToolBar.prototype.elements.ol = {
- type: 'button',
- title: 'Ordered list',
- fn: {
- wiki: function() {
- this.encloseLineSelection('','',function(str) {
- str = str.replace(/\r/g,'');
- return str.replace(/(\n|^)[*-]?\s*/g,"$1# ");
- });
- }
- }
-}
-
-// spacer
-jsToolBar.prototype.elements.space3 = {type: 'space'}
-
-// bq
-jsToolBar.prototype.elements.bq = {
- type: 'button',
- title: 'Quote',
- fn: {
- wiki: function() {
- this.encloseLineSelection('','',function(str) {
- str = str.replace(/\r/g,'');
- return str.replace(/(\n|^) *([^\n]*)/g,"$1> $2");
- });
- }
- }
-}
-
-// unbq
-jsToolBar.prototype.elements.unbq = {
- type: 'button',
- title: 'Unquote',
- fn: {
- wiki: function() {
- this.encloseLineSelection('','',function(str) {
- str = str.replace(/\r/g,'');
- return str.replace(/(\n|^) *[>]? *([^\n]*)/g,"$1$2");
- });
- }
- }
-}
-
-// pre
-jsToolBar.prototype.elements.pre = {
- type: 'button',
- title: 'Preformatted text',
- fn: {
- wiki: function() { this.encloseLineSelection('<pre>\n', '\n</pre>') }
- }
-}
-
-// spacer
-jsToolBar.prototype.elements.space4 = {type: 'space'}
-
-// wiki page
-jsToolBar.prototype.elements.link = {
- type: 'button',
- title: 'Wiki link',
- fn: {
- wiki: function() { this.encloseSelection("[[", "]]") }
- }
-}
-// image
-jsToolBar.prototype.elements.img = {
- type: 'button',
- title: 'Image',
- fn: {
- wiki: function() { this.encloseSelection("!", "!") }
- }
-}
diff --git a/public/javascripts/jstoolbar/textile.js b/public/javascripts/jstoolbar/textile.js
new file mode 100644
index 000000000..c461b9d2e
--- /dev/null
+++ b/public/javascripts/jstoolbar/textile.js
@@ -0,0 +1,200 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * This file is part of DotClear.
+ * Copyright (c) 2005 Nicolas Martin & Olivier Meunier and contributors. All
+ * rights reserved.
+ *
+ * DotClear is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * DotClear is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with DotClear; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * ***** END LICENSE BLOCK *****
+*/
+
+/* Modified by JP LANG for textile formatting */
+
+// strong
+jsToolBar.prototype.elements.strong = {
+ type: 'button',
+ title: 'Strong',
+ fn: {
+ wiki: function() { this.singleTag('*') }
+ }
+}
+
+// em
+jsToolBar.prototype.elements.em = {
+ type: 'button',
+ title: 'Italic',
+ fn: {
+ wiki: function() { this.singleTag("_") }
+ }
+}
+
+// ins
+jsToolBar.prototype.elements.ins = {
+ type: 'button',
+ title: 'Underline',
+ fn: {
+ wiki: function() { this.singleTag('+') }
+ }
+}
+
+// del
+jsToolBar.prototype.elements.del = {
+ type: 'button',
+ title: 'Deleted',
+ fn: {
+ wiki: function() { this.singleTag('-') }
+ }
+}
+
+// code
+jsToolBar.prototype.elements.code = {
+ type: 'button',
+ title: 'Code',
+ fn: {
+ wiki: function() { this.singleTag('@') }
+ }
+}
+
+// spacer
+jsToolBar.prototype.elements.space1 = {type: 'space'}
+
+// headings
+jsToolBar.prototype.elements.h1 = {
+ type: 'button',
+ title: 'Heading 1',
+ fn: {
+ wiki: function() {
+ this.encloseLineSelection('h1. ', '',function(str) {
+ str = str.replace(/^h\d+\.\s+/, '')
+ return str;
+ });
+ }
+ }
+}
+jsToolBar.prototype.elements.h2 = {
+ type: 'button',
+ title: 'Heading 2',
+ fn: {
+ wiki: function() {
+ this.encloseLineSelection('h2. ', '',function(str) {
+ str = str.replace(/^h\d+\.\s+/, '')
+ return str;
+ });
+ }
+ }
+}
+jsToolBar.prototype.elements.h3 = {
+ type: 'button',
+ title: 'Heading 3',
+ fn: {
+ wiki: function() {
+ this.encloseLineSelection('h3. ', '',function(str) {
+ str = str.replace(/^h\d+\.\s+/, '')
+ return str;
+ });
+ }
+ }
+}
+
+// spacer
+jsToolBar.prototype.elements.space2 = {type: 'space'}
+
+// ul
+jsToolBar.prototype.elements.ul = {
+ type: 'button',
+ title: 'Unordered list',
+ fn: {
+ wiki: function() {
+ this.encloseLineSelection('','',function(str) {
+ str = str.replace(/\r/g,'');
+ return str.replace(/(\n|^)[#-]?\s*/g,"$1* ");
+ });
+ }
+ }
+}
+
+// ol
+jsToolBar.prototype.elements.ol = {
+ type: 'button',
+ title: 'Ordered list',
+ fn: {
+ wiki: function() {
+ this.encloseLineSelection('','',function(str) {
+ str = str.replace(/\r/g,'');
+ return str.replace(/(\n|^)[*-]?\s*/g,"$1# ");
+ });
+ }
+ }
+}
+
+// spacer
+jsToolBar.prototype.elements.space3 = {type: 'space'}
+
+// bq
+jsToolBar.prototype.elements.bq = {
+ type: 'button',
+ title: 'Quote',
+ fn: {
+ wiki: function() {
+ this.encloseLineSelection('','',function(str) {
+ str = str.replace(/\r/g,'');
+ return str.replace(/(\n|^) *([^\n]*)/g,"$1> $2");
+ });
+ }
+ }
+}
+
+// unbq
+jsToolBar.prototype.elements.unbq = {
+ type: 'button',
+ title: 'Unquote',
+ fn: {
+ wiki: function() {
+ this.encloseLineSelection('','',function(str) {
+ str = str.replace(/\r/g,'');
+ return str.replace(/(\n|^) *[>]? *([^\n]*)/g,"$1$2");
+ });
+ }
+ }
+}
+
+// pre
+jsToolBar.prototype.elements.pre = {
+ type: 'button',
+ title: 'Preformatted text',
+ fn: {
+ wiki: function() { this.encloseLineSelection('<pre>\n', '\n</pre>') }
+ }
+}
+
+// spacer
+jsToolBar.prototype.elements.space4 = {type: 'space'}
+
+// wiki page
+jsToolBar.prototype.elements.link = {
+ type: 'button',
+ title: 'Wiki link',
+ fn: {
+ wiki: function() { this.encloseSelection("[[", "]]") }
+ }
+}
+// image
+jsToolBar.prototype.elements.img = {
+ type: 'button',
+ title: 'Image',
+ fn: {
+ wiki: function() { this.encloseSelection("!", "!") }
+ }
+}