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