Chris@909: /* ***** BEGIN LICENSE BLOCK ***** Chris@909: * This file is part of DotClear. Chris@909: * Copyright (c) 2005 Nicolas Martin & Olivier Meunier and contributors. All Chris@909: * rights reserved. Chris@909: * Chris@909: * DotClear is free software; you can redistribute it and/or modify Chris@909: * it under the terms of the GNU General Public License as published by Chris@909: * the Free Software Foundation; either version 2 of the License, or Chris@909: * (at your option) any later version. Chris@909: * Chris@909: * DotClear is distributed in the hope that it will be useful, Chris@909: * but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@909: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@909: * GNU General Public License for more details. Chris@909: * Chris@909: * You should have received a copy of the GNU General Public License Chris@909: * along with DotClear; if not, write to the Free Software Chris@909: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Chris@909: * Chris@909: * ***** END LICENSE BLOCK ***** Chris@909: */ Chris@909: Chris@909: /* Modified by JP LANG for textile formatting */ Chris@909: Chris@909: // strong Chris@909: jsToolBar.prototype.elements.strong = { Chris@909: type: 'button', Chris@909: title: 'Strong', Chris@909: fn: { Chris@909: wiki: function() { this.singleTag('*') } Chris@909: } Chris@909: } Chris@909: Chris@909: // em Chris@909: jsToolBar.prototype.elements.em = { Chris@909: type: 'button', Chris@909: title: 'Italic', Chris@909: fn: { Chris@909: wiki: function() { this.singleTag("_") } Chris@909: } Chris@909: } Chris@909: Chris@909: // ins Chris@909: jsToolBar.prototype.elements.ins = { Chris@909: type: 'button', Chris@909: title: 'Underline', Chris@909: fn: { Chris@909: wiki: function() { this.singleTag('+') } Chris@909: } Chris@909: } Chris@909: Chris@909: // del Chris@909: jsToolBar.prototype.elements.del = { Chris@909: type: 'button', Chris@909: title: 'Deleted', Chris@909: fn: { Chris@909: wiki: function() { this.singleTag('-') } Chris@909: } Chris@909: } Chris@909: Chris@909: // code Chris@909: jsToolBar.prototype.elements.code = { Chris@909: type: 'button', Chris@909: title: 'Code', Chris@909: fn: { Chris@909: wiki: function() { this.singleTag('@') } Chris@909: } Chris@909: } Chris@909: Chris@909: // spacer Chris@909: jsToolBar.prototype.elements.space1 = {type: 'space'} Chris@909: Chris@909: // headings Chris@909: jsToolBar.prototype.elements.h1 = { Chris@909: type: 'button', Chris@909: title: 'Heading 1', Chris@909: fn: { Chris@909: wiki: function() { Chris@909: this.encloseLineSelection('h1. ', '',function(str) { Chris@909: str = str.replace(/^h\d+\.\s+/, '') Chris@909: return str; Chris@909: }); Chris@909: } Chris@909: } Chris@909: } Chris@909: jsToolBar.prototype.elements.h2 = { Chris@909: type: 'button', Chris@909: title: 'Heading 2', Chris@909: fn: { Chris@909: wiki: function() { Chris@909: this.encloseLineSelection('h2. ', '',function(str) { Chris@909: str = str.replace(/^h\d+\.\s+/, '') Chris@909: return str; Chris@909: }); Chris@909: } Chris@909: } Chris@909: } Chris@909: jsToolBar.prototype.elements.h3 = { Chris@909: type: 'button', Chris@909: title: 'Heading 3', Chris@909: fn: { Chris@909: wiki: function() { Chris@909: this.encloseLineSelection('h3. ', '',function(str) { Chris@909: str = str.replace(/^h\d+\.\s+/, '') Chris@909: return str; Chris@909: }); Chris@909: } Chris@909: } Chris@909: } Chris@909: Chris@909: // spacer Chris@909: jsToolBar.prototype.elements.space2 = {type: 'space'} Chris@909: Chris@909: // ul Chris@909: jsToolBar.prototype.elements.ul = { Chris@909: type: 'button', Chris@909: title: 'Unordered list', Chris@909: fn: { Chris@909: wiki: function() { Chris@909: this.encloseLineSelection('','',function(str) { Chris@909: str = str.replace(/\r/g,''); Chris@909: return str.replace(/(\n|^)[#-]?\s*/g,"$1* "); Chris@909: }); Chris@909: } Chris@909: } Chris@909: } Chris@909: Chris@909: // ol Chris@909: jsToolBar.prototype.elements.ol = { Chris@909: type: 'button', Chris@909: title: 'Ordered list', Chris@909: fn: { Chris@909: wiki: function() { Chris@909: this.encloseLineSelection('','',function(str) { Chris@909: str = str.replace(/\r/g,''); Chris@909: return str.replace(/(\n|^)[*-]?\s*/g,"$1# "); Chris@909: }); Chris@909: } Chris@909: } Chris@909: } Chris@909: Chris@909: // spacer Chris@909: jsToolBar.prototype.elements.space3 = {type: 'space'} Chris@909: Chris@909: // bq Chris@909: jsToolBar.prototype.elements.bq = { Chris@909: type: 'button', Chris@909: title: 'Quote', Chris@909: fn: { Chris@909: wiki: function() { Chris@909: this.encloseLineSelection('','',function(str) { Chris@909: str = str.replace(/\r/g,''); Chris@909: return str.replace(/(\n|^) *([^\n]*)/g,"$1> $2"); Chris@909: }); Chris@909: } Chris@909: } Chris@909: } Chris@909: Chris@909: // unbq Chris@909: jsToolBar.prototype.elements.unbq = { Chris@909: type: 'button', Chris@909: title: 'Unquote', Chris@909: fn: { Chris@909: wiki: function() { Chris@909: this.encloseLineSelection('','',function(str) { Chris@909: str = str.replace(/\r/g,''); Chris@909: return str.replace(/(\n|^) *[>]? *([^\n]*)/g,"$1$2"); Chris@909: }); Chris@909: } Chris@909: } Chris@909: } Chris@909: Chris@909: // pre Chris@909: jsToolBar.prototype.elements.pre = { Chris@909: type: 'button', Chris@909: title: 'Preformatted text', Chris@909: fn: { Chris@909: wiki: function() { this.encloseLineSelection('
\n', '\n
') } Chris@909: } Chris@909: } Chris@909: Chris@909: // spacer Chris@909: jsToolBar.prototype.elements.space4 = {type: 'space'} Chris@909: Chris@909: // wiki page Chris@909: jsToolBar.prototype.elements.link = { Chris@909: type: 'button', Chris@909: title: 'Wiki link', Chris@909: fn: { Chris@909: wiki: function() { this.encloseSelection("[[", "]]") } Chris@909: } Chris@909: } Chris@909: // image Chris@909: jsToolBar.prototype.elements.img = { Chris@909: type: 'button', Chris@909: title: 'Image', Chris@909: fn: { Chris@909: wiki: function() { this.encloseSelection("!", "!") } Chris@909: } Chris@909: }