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